Jump to content
  • Advertisement
Sign in to follow this  
IrYoKu

OpenGL Problem with lighting in back faces

This topic is 5060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I see... well then the most reasonable explanation is that we're dealing with per-vertex lighting, meaning that the lighting is not calculated for every pixel, but for every vertex and just gets interpolated. Atrifacts like that are bound to happen. For example, take a triangle: Let's assume that in the real world, the corners should be lit but it should be dark in the middle. With GL per-vertex lighting, if the corners(vertices) are lit, so will be the whole triangle.

Share this post


Link to post
Share on other sites
Advertisement
I have been thinking about this for a while, and I think it's really the better explanation, at least when using smooth shading.

It's curious, but when using flat shading (in my program I calculated the correct normals for both modes, it's user selectable), that doesn't interpolate between vertices, I can see the same problem. So, just to be sure, I have written a small function that draws every normal in the surface. They look to be correct. But then, when I see the surface from the bottom, I can see the normal of the faces that are lit (I have a key to switch to wireframe mode so I can see through the faces), and I am sure that the angle is more than 90º for the vertex that is used to colorize the face.

Maybe when the angle is negative, you cannot expect anything, the result is undefined, because it's not expected to see the back of a face, because maybe it's mean to be inside of a model.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!