View Full Version : Back FACE lighting????
03-19-2002, 11:30 PM
In my program the inside of the objects seems to be very dark. I can see this when I use a clipping plane or when I delete some triangles of the mesh enabling the user to see the inside.
glCullFace is disabled!!
What is wrong? Does anybody know how I can implement back face lighting?
Thanks in advance,
03-19-2002, 11:54 PM
Over to you, painterb...
03-20-2002, 12:31 AM
you might want to use glLightModel
03-20-2002, 01:51 AM
Use glLightModel, no really, like that wasn't obvious. Don't you just love it when people are helpful.
Anyway with lighting enabled I assume you have lighting working properly enable lighting the front and back side with glLightModel.
The problem you are probably running into is most likely related to normals. Number one you must specify the normals (on a per vertex basis) that will be used to calculate the light at each vertex. Please correct me if I am wrong but this is the impression I get (consult the spec to be more accurate),l with lighting of Back and Front Faces the normal still only points one way. OpenGL it appears calculates light with normals and then just colors both sides of the face. I don't believe it actually flips the normals (if the light is on the back side of the face). At least in my experience it never seems too (although I haven't really ever needed to light the back side of faces).
THe other problem which I figure you are aware of since this is the advanced forum is that (like I said) OpenGL calculates light per vertex which means that lighting may not look very good or even be close to the way you expect without good tesselation of the the geometry.
Hope this helps.
03-20-2002, 03:18 AM
I thought that OpenGL would light up both back and front faces by default.
03-20-2002, 07:02 AM
Originally posted by Devulon:
I don't believe it actually flips the normals
Don't believe... Search for an answer.
OpenGL specification version 1.3, section 2.13.1 : Lighting
Lighting may operate in two-sided mode (tbs = TRUE), in which a front color
is computed with one set of material parameters (the front material) and a back
color is computed with a second set of material parameters (the back material).
This second computation replaces n with -n.
03-20-2002, 12:02 PM
Originally posted by knackered:
Over to you, painterb...
Now that wasn't so hard was it? http://www.opengl.org/discussion_boards/ubb/smile.gif
Try researching glLightModelfv ( GL_LIGHT_MODEL_TWO_SIDE , GL_TRUE ) and make sure you're using glMaterialfv ( GL_FRONT_AND_BACK , GL_AMBIENT_AND_DIFFUSE , color ) correctly for what you're doing.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.