PDA

View Full Version : Simulating sun light



Javac
10-13-2003, 11:47 PM
I'd like to simulate some sun light in my 3d scene.
I'm putting the light position in one of my defined 3d space corners,but I still get the ambient lighting effect.
How can create one direction light effect?
From some books what I understand is - that for this I must use diffuse light.
In OpenGL gl/glu libraries I found only
ambient lighting module.

10-14-2003, 01:00 AM
To properly represent something like the sun, you'll want to place the light at infinity. Take a look at the documentation for light position parameters - you'll want to set the fourth parameter to 0 to set the light at infinity, but remember to disable attenuation.

Anyway, removing ambient lighting. Obviously you'll need to set the ambient component of any lights you use to black, but the trick is that there's a global ambient component totally seperate from the GL_LIGHTx lights, and it has a non-zero default. Take a look at glLightModel with respect to GL_LIGHT_MODEL_AMBIENT:
http://tc1.chemie.uni-bielefeld.de/doc/OpenGL/hp/Reference/glLightModel.html

10-14-2003, 01:03 AM
Addendum: And yes, you'll need to use diffuse lighting. It's set in basically the same way as ambient. Take a look at the docs for glLight:
http://tc1.chemie.uni-bielefeld.de/doc/OpenGL/hp/Reference/glLight.html