|
I dynamically create meshes at runtime, and sometimes they end up inside-out (see this question). I thought I had solved the problem with a clockwise-detection script, but there are still random instances where it fails, causing the surface normals to point inwards. My question is, would it be possible to simply "double" the triangle list, with the second half being reversed, therefore creating a two-sided, "hollow" object, so that no matter if it was "inside-out" or not, it would still look and function correctly? I have a MeshCollider on these objects (they're static), and when the surface normals face the wrong way, objects become "trapped" inside the object instead of bouncing off of them, if that makes sense. This is what I'm trying to prevent.
(comments are locked)
|
|
So it turns out I can do this (creating a "hollow" object, with normals facing inward and outward), and it works great. The downsides, however, are that your UV mapping and/or shadowing might get screwed up, as mine did. Luckily I was able to use an unlit diffuse shader which still looks good. The other problem is that you're drawing unnecessary triangles (literally, twice as many) inside the object. For objects with as few triangles as mine, this doesn't pose a problem, but for larger objects it may. @SpikeX, you managed to checkmark your answer after 6 hours? The one time I tried, UA invoked a 2-day delay. Guess 5K has it's perks after all... :)
Jul 08 '10 at 02:29 AM
Cyclops
I think it's because I asked it four days ago ;)
Jul 08 '10 at 05:54 AM
qJake
(comments are locked)
|

@SpikeX, is it really random failures, or are there specific shapes where it fails? Remember that the algorithm doesn't work for some shapes - such as self-intersecting shapes, or shapes with holes. How does your drawing algorithm work? Could it be generating some of these invalid shapes?
The shapes are pre-checked. They are solid, and non-intersecting. They're also limited to a certain size (not too few or too many datapoints, basically). And yes, it's random. Say, one out of every 50 triangles drawn exhibits this weird behavior. It's entirely non-reproducable.