Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Weev · Jun 25, 2010 at 07:29 PM · shadertexturemeshmaterialclipping

Mesh Clipping / Cross Sections

I've seen a few examples of creating shaders to get a "cross section" effect for objects, as seen in these examples on the Unity Forums:

Shader for Clipping Plane
Simple Cross Section Shader

These shaders affect all objects that have the shader attached to them, however, and I need some way to have a different cross section on different instances of the same mesh (generated at runtime). I've thought about creating a separate instance of a material for each object (and then perhaps replacing the material once the effect is no longer needed), but this seems like it might not be the best idea.

Is there a simple way to get a cross section of a mesh (with or without a shader)? I don't necessarily need the "cut off" sections of the mesh to be capped, so a simple clipping plane is all I need, but I don't know if there's a way to make arbitrary clipping planes and move them around. I also need to be able to change how much of a mesh is "cut off" by moving a clipping plane or adjusting shader values (or something similar) at runtime. For my particular problem I just need everything above a certain point to be transparent - only put the material on the mesh up to a certain point. So if there's a way to dynamically chop the mesh off at a certain point, that would be fine.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Max Kaufmann · Aug 02, 2010 at 05:44 PM

Dup the material using UnityEngine.Material's cloning constructor, and then feed the clipping plane values as uniforms to the instanced pixel shaders.

Not duplicating the materials means that they have to share uniforms, which exhibits the for-all-objects behavior you describe.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

[ problem ] transparent shader !!! 1 Answer

Textures not showing up 0 Answers

Multiple materials on same object 0 Answers

Triplanar surface shader not responding to Mesh.Colors 0 Answers

Texture2D to Texture3D 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges