Differerence between positioned and directed light

Started by
1 comment, last by Fiddler 14 years, 6 months ago
hey i'm doing a lighting tutorial on videotutorialsrock.com and i'm a bit confused between positioned light and directed light. The only difference is the 4th parameter of lighthPos0[] and lightPos1[]. Could someone please explain the difference between these two ways of lighting, preferably with some sort of analogy which would make it clear, e.g. Sun, or torch or lightbulb etc. cos that might make it easier to understand :)

//Add positioned light 
GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color (0.5, 0.5, 0.5) 
GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 1.0f}; //Positioned at (4, 0, 8)
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0); 
glLightfv(GL_LIGHT0, GL_POSITION,lightPos0); 

	
//Add directed light 
GLfloat lightColor1[] = {0.5f, 0.2f, 0.2f, 1.0f}; //Color (0.5, 0.2, 0.2)
GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f}; 
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);
thanx
Advertisement
There are 3 most common types of lights used in 3D environments:

Point Lights,
Spot Lights,
Directional Lights


Point lights are like a typical light bulb. They emit light from a certain point in space.

Spot lights are similar to point lights in that they emit light from a point in space, but the direction into which they photons are emitted is limited by a certain angle offset from the direction. Think of typical spot lights used on a stage.

Directional lights are different from the previous two by the fact that all the light rays are parallel to each other. In reality this never happens, however, when a light source is very distant (e.g. sun, moon) the difference in angle of the incoming rays is so small that you could say they are parallel.

As you can see, you only need to define the source point of the light for the first two, whereas the directional light only requires the direction of the light rays in space. The direction of light rays for point and spot lights is implicitly defined by the vector from the light source point towards the object being lit and depends on the relative position of both in space.
The redbook (available online) explains the math behind each light type. If you wish to understand it using a "hands-on" approach, you should try implementing each type using shaders. It's an enlightening experience, if you catch my drift. ;)

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

This topic is closed to new replies.

Advertisement