• Advertisement
Sign in to follow this  

Vertex winding for Volume Shadows

This topic is 4149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to implement volume (or stencil) shadows at the moment and have come to a stand-still. In order to run the algorithm efficiently, you need to have a orientations of all the edges in a mesh consistent. What I need is an algorithm for determining if a triangle is wound correctly and otherwise fixing it. So for example, the following tri would be fine:
   3
  /  /   1-----2
Assuming the face normal points toward you, the vertices are ordered correctly around the normal (anti-clockwise). This is not good however:
   2
  /  /   1-----3
The vertices are number around the wrong way. Is there a way of testing which way around the vertices are given I have the vertex positions and the face normal??? I realise that if I have a test for it then the simple solution is to swap verts 2 and 3, but how do I test that this is the case?

Share this post


Link to post
Share on other sites
Advertisement
Test the cross product

(v2-v1)x(v3-v1)

if it points to the same direction as your normal your triangle is ok. Otherwise swap v2 and v3.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement