# Vertex winding for Volume Shadows

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

## 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 on other sites
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.

1. 1
Rutin
73
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633426
• Total Posts
3011812
• ### Who's Online (See full list)

There are no registered users currently online

×