Normal Independent Lightning


I’m using OpenGL for a viewer of models where the triangles have normals in arbitrary directions. Sometimes the normal points inside and sometimes outside.

This makes my models look like a chequered surface and the hidden surface removal does not match with the lightning.

Is there a setting where OpenGL can light the models correctly independent of the normal direction?

If not, is there a function which automatically aligns all normals?

/Jonas Forssell, Gothenburg, Sweden

What do you exactly mean ? Does your normals that point inside the model should point outside ? Is that what you mean ?

well it’s sort of possible, you can read the gl_FrontFacing variable in the fragmentshader and then if it’s back facing you can reverse the normal.

But it is much better to get the model normals correct before viewing them.