Search code examples
mathopengltexture-mapping

Where is the triangle normal pointing so I can map correctly?


Here is what I have so far. I have a 3D model and I made a triangle mesh. Calculated and applied normals to the model too. I want to apply different textures into the triangle. I also have the direction vector of all the texture I need.

For mapping, I do this:
I just calculate the Dot product of each triangle normal with the texture direction vector of each texture, and start comparing to see which texture could suitable BASED UPON the calculation of dot product.

But I realised that it is not as straight forward as I thought it was. Because two or more, different triangle could be in almost same orientation in 3D space, meaning one could be facing towards me and the other could be facing opposite direction (maybe parallel but different direction).

I think a better question is how do I use the calculated dot-product to distinguish the face of the triangle so I know I know which image/texture should be used ?


Solution

  • If the triangles are facing in opposite directions, the normals will also face in opposite directions, and the dot products will have opposite signs. Therefore the dot product gives you enough information to distinguish between the opposite faces. I can't think of a simple test which would give better results than the dot product.