Calculating normals for mesh: More odd lighting stuff...

Started by
1 comment, last by jesse007 12 years, 7 months ago
So, I've been trying to get an OBJ file to look good under lighting to no avail. I got a little closer with some help earlier, but I'm kind of stuck again. I've got an OBJ file that has vertices and face data in it. For each vertex I basically calculate the normal for it's associated faces then average the normals to create one vector for that vertex. Here is the result of that:

[media]http://i.imgur.com/2k5Lp.png[/media]


And here's the normals "visualized" (lol):


[media]http://i.imgur.com/BqrmD.png[/media]


Any suggestions as to why this looks so weird? Is it my lighting? My normal calculations? Another thing that I heard about was duplicated shared vertices and assigning different vectors. Would that do the trick? Any guidance would be greatly appreciated!!
Advertisement
Have you tried face-normals in your shading code?
Then every face should have one colour. (doesn't look nice, but perhaps it helps you out)
Also visualized face normals could be checked better (than the vertex normals).

I would say it looks like your interpolation or shading is broken. (but that's only a guess, I don't know your code)

Another idea: OBJ face-orientation is counterclockwise and (for example) DirectX standard is clockwise.
Does this match in your case?
(don't know what you are using, also DirectX can be "convinced" :) to use counterclockwise orientation)

Any suggestions as to why this looks so weird? Is it my lighting? My normal calculations? Another thing that I heard about was duplicated shared vertices and assigning different vectors. Would that do the trick? Any guidance would be greatly appreciated!!


Did you already try your lighting shader on a sphere? Sometimes the orientation of the faces on a model is not consistent and this can screw up the lighting. My suggestion is to rule out the model by applying your shader code on a simple sphere or a teapot first. Once you get that working, you can be sure that your code is good and then you can check your .obj model again.
Good judgment comes from experience; experience comes from bad judgment.

This topic is closed to new replies.

Advertisement