x


How do I make a vertex invisible if its X value is > myFloat

I am trying to cut off part of a mesh (coming from a 3D scanner, with a lot of unesscessary surface data).

The problem is basically a Mesh and a box , and everything that sticks outside of the box becomes invisible. Can this be done? This could be done by testing the entire mesh (each vertex) on x values, y values and so on.

I tried looking at shaders and colors, but they require special "Particle shaders" to work. This is a little bit above my head at the moment, so I would be immensely grateful if someone could give me a hint.

PS : Another option is to move all the vertexes outside of this boundary downward or away somehow. Is this simpler?

Best regards Jens

more ▼

asked Sep 21 '10 at 06:28 AM

Jens T gravatar image

Jens T
138 6 7 17

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I don't have a definite answer for you, but I'll offer a couple of comments.

You might be a bit confused about shaders. 'Particle shaders' are just shaders whose parameters are suitable for rendering particle effects; they're not some sort of fundamental feature of Unity, nor do they really have any bearing on the problem at hand. You can certainly make an object translucent or transparent without dealing with 'particle shaders', and most likely without dealing with shaders directly at all.

Now, whether making parts of your mesh transparent is an appropriate solution here, I really can't say, since I don't fully understand what problem you're trying to solve. If the objective is to remove these parts of the mesh permanently, then that's probably not what you want. If however you want to hide parts of the mesh dynamically, you could do this be changing the vertex colors (assuming you're using an appropriate shader, but I believe there are built-in shaders that will handle this). Note that if the mesh is 'smoothed' (that is, vertices are generally shared), triangles that cross the box's boundaries may end up being translucent (and gradated) rather than fully transparent.

As for moving vertices, if you didn't 'disconnect' the moved vertices by deleting triangles, you'd end up with (presumably large) triangles connecting the 'main' part of the mesh with the 'moved' part, which I doubt is what you want.

You can edit the mesh in whatever way you want via the Unity API, so if you wanted to clip the mesh to the box (either roughly by removing triangles, or exactly by clipping triangles), you certainly could. However, what you describe sounds like it would probably be better handled by a dedicated modeling application (unless you specifically want this to be an interactive, in-game process).

more ▼

answered Sep 21 '10 at 08:45 AM

Jesse Anders gravatar image

Jesse Anders
7.3k 7 17 48

I suspect the reference to particle shaders is due to most of those shaders' ability to use vertex colors, which the rest of the standard shaders don't use.

Sep 21 '10 at 10:52 AM Eric5h5

That makes sense. I was under the impression there was a shader in the Transparent category that used vertex colors, but I must have misremembered.

Sep 21 '10 at 01:38 PM Jesse Anders
(comments are locked)
10|3000 characters needed characters left

You might be able to use the shaders in this topic on the Unity forums.

more ▼

answered Sep 21 '10 at 10:52 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1649
x147
x138
x137

asked: Sep 21 '10 at 06:28 AM

Seen: 1383 times

Last Updated: Sep 21 '10 at 06:28 AM