Differerence between positioned and directed light

This topic is 3344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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);

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

Share on other sites
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.

Share on other sites
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. ;)

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 10
• Forum Statistics

• Total Topics
633653
• Total Posts
3013155
×

Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!