Original Post
I need to implement directional lighting for a very basic terrain engine. I have a skydome with a texture that includes clouds and the sun. I have some generated terrain with all calculated normals. The sun has a 3D position on the skydome of ( -86.6f, 72.9f, 491.2f). So I need my directional light to be from the direction of the sun to (0, 0, 0).
The documentation for the glLightfv command with pname GL_POSITION states that if the w component of the position is 0.0 then the light is treated as a directional source. But you are still only giving the position of a point in 3D space to OpenGL. To specify a direction you need to have two points. Or does OpenGL already have a default second point? If so is this (0.0, 0.0, 0.0)? Please explain just how the direction is calculated.
The commands I use at the moment are:
GLfloat LightPosition[] = {-86.6f, 72.9f, 491.2f, 0.0f};
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
The documentation for the glLightfv command with pname GL_POSITION states that if the w component of the position is 0.0 then the light is treated as a directional source. But you are still only giving the position of a point in 3D space to OpenGL. To specify a direction you need to have two points. Or does OpenGL already have a default second point? If so is this (0.0, 0.0, 0.0)? Please explain just how the direction is calculated.
The commands I use at the moment are:
GLfloat LightPosition[] = {-86.6f, 72.9f, 491.2f, 0.0f};
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);