PDA

View Full Version : Normals pointing inward



Mark1715
02-28-2005, 05:10 PM
Please excuse my ignorance. I am reading OFF files and computing normals for lighting and some of the models come out fine and some of the models appear to be lit on the inside which i think means that the normals are pointed inward. So how do i differentiate the models that have the normals pointing inward and the ones that will display fine.

mikael_aronsson
03-01-2005, 12:44 AM
It is not that easy to detect, but if all normals points in the wrong direction you might simply flip all normals when you load the model, but as I said it is not easy to make this automatic because what is the inside and the outside of your model.

It is possible to detect it, at least if the model is closed, but it takes some coding to do it.

You might consider using doublesided lighting to improve things a bit.

Mikael

Ominae392
03-02-2005, 07:30 AM
Something I do at work is calculate the centroid of the object after it has loaded. I then calculate the angle between the vector formed from the centroid to a random indice of a few different faces to the normal vector of each of those faces. If I notice there is a lack of large angles formed I just flip all the normals.

I also add a button to all 3D loaders I write to do the flipping. Given that I can renormal an object with 150k+ vertices and 300k+ faces in under a second that cost of adding this function is cheap.

Aeluned
03-02-2005, 08:36 AM
I think you can also just reverse the winding.
glFrontFace(GL_CCW or GL_CW).