Back FACE lighting????

Hello,

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,

Billy.

Over to you, painterb…

you might want to use glLightModel

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.

Happy Coding.

Thanks, Devulon.

I thought that OpenGL would light up both back and front faces by default.

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.

Originally posted by knackered:
Over to you, painterb…

Now that wasn’t so hard was it?

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.