PDA

View Full Version : Problems with lighting



mcbastian
01-12-2001, 02:35 AM
Hi!

I have al little problem with Lighting.
when i put a object on screen, colored red
(
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);glVertex3f(blah...);
bla....
)

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,

sebastian.

Bob
01-12-2001, 03: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.

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

Before drawing the polygon you should give it a normal like this:
glNormal3f(1.0f,0.0f,0.0f);
This face is 'looking' to the dir X=1, Y=0, Z=0

coco
01-16-2001, 10: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.

mcbastian
01-19-2001, 03: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

Bastian.