PDA

View Full Version : How to detect backface of polygon?



Nitisara
12-13-2005, 12:20 AM
I have failed to find the way to detect if it is a backface of polygon in a shader handler plugin.
Technically it should be possible by analyzing direction of gNorm vector, but it is always directed towards viewing ray, despite it is face or backface of a polygon.
Can anyone help, please? :help:

Jarno
12-13-2005, 07:34 PM
Compute the polygon normal yourself (cross product of the vector from the first vertex to the second, and the vector from the first vertex to the last vertex), and compare the ray direction with that (check the sign of the dot product of the normal and ray direction).

---JvdL---
\

Nitisara
12-14-2005, 06:11 PM
Compute the polygon normal yourself.
Thank you very much! It helped! :thumbsup: