• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Texture2D to Texture3D 2 Answers

Assign Texture To Material Unity 4.6 1 Answer

How to fix a object intersection problem? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges