Jump to content
  • Advertisement
Sign in to follow this  
gargoyle

Differerence between positioned and directed light

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

If you intended to correct an error in the post then please contact us.

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

	
//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

Share this post


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

Share this post


Link to post
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. ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!