View Full Version : Problems with lighting

01-12-2001, 01:35 AM

I have al little problem with Lighting.
when i put a object on screen, colored red

the triangle is displayed red. when i put a white lightsource in the scene, the object is displayed only black and white, independend of: normal, diffuse, secular, ambient values. (gl_smooth is on)
the next problem is, if a triangle is on the same line (say, middle on z-axis, lightsource in 0,0,0) the triangle BEHIND this is also lighting.....?
ligthing is my last big opengl-problem :-)

thanks for help,


01-12-2001, 02:17 AM
Do you setup material properties, and not only light properties? glColor*() got no effect when lighing is on.

And second, do you mean that you have two triangles in a row, and you expect the one close to the light to cast a shadow on the other one? If so, then forget it. No offense, but shadows is up to you do do. OpenGL draws whatever you want it to draw, and don't care about what has already been drawn or what will be drawn.

01-16-2001, 05:53 AM
and the Normals???

Before drawing the polygon you should give it a normal like this:
This face is 'looking' to the dir X=1, Y=0, Z=0

01-16-2001, 09:55 AM
You can use glColor if you enable Color Material (see glEnable(GL_COLOR_MATERIAL)) instead of glMaterial, its easier to play with maybe.

And yes, surface normals are absolutelly needed. You have to provide them, since opengl wont calculate them. GLU functions will generate normals for the GLU primitives if you ask for it.

01-19-2001, 02:50 AM
Yeah, this helped a lot. i forgot to say that i use glNormals...

btw: I'm now trying to make a shadow-system. http://www.opengl.org/discussion_boards/ubb/smile.gif