In the OpenGL red book, this statement is made about two-sided lighting:
OpenGL reverses the surface normals for back-facing polygons; typically, this means that the surface normals of visible back- and front-facing polygons face the viewer, rather than pointing away. As a result, all polygons are illumnated correctly.
I tried to enable this normal-flipping in arb_vertex_program by doing the obvious:
but it seems to only affect colors, not normals. How can I get that normal reversal based on facedness to happen in ARB_vertex_program? If it cannot be done automatically, is it even possible to detect triangle winding in a VP?
[This message has been edited by Zeno (edited 12-26-2003).]
[This message has been edited by Zeno (edited 12-26-2003).]
calculate lighting with negative of the normal (using the back material properties)
Write the result of the front lighting to result.color.front
Write the result of the back lighting to result.color.back
(Note you can access front and back material properties - ie. state.lightprod[n].front/back.xxxx)
You cannot access if the vertex is on a forward or backward winding polygon as (with an index array) it could be used in both a forward and backward winding polygon.
I have not actually done this myself, so someone with more experience may be able to help more.