Jump to content
• Advertisement

Public Group

# Directional lights?

This topic is 3798 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

I'm learning how to use lighting from this tutorial: http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B9.aspx#still. The example used there is a diffuse light. What I don't understand is where the light is coming from (what coords/direction). The tutorial only describes where the line is shining towards. I'm not sure if it has a static location or if you have to define it yourself. Here's the light I want to use:
    D3DLIGHT9 light, light2;

ZeroMemory(&light, sizeof(light));
ZeroMemory(&light2, sizeof(light2));
light2.Type = light.Type = D3DLIGHT_DIRECTIONAL;
light2.Diffuse.r = light.Diffuse.r = 0.5f;
light2.Diffuse.g = light.Diffuse.g = 0.5f;
light2.Diffuse.b = light.Diffuse.b = 0.5f;
light2.Diffuse.a = light.Diffuse.a = 1.0f;

D3DVECTOR vecDirection = {-1.0f, -0.3f, -1.0f};
light.Direction = vecDirection;

D3DVECTOR vecDirection2 = {1.0f, 0.3f, 1.0f}; //where does the light come from?
light2.Direction = vecDirection2;

d3ddev->SetLight(0, &light);
d3ddev->LightEnable(0, TRUE);
d3ddev->SetLight(1, &light2);
d3ddev->LightEnable(1, TRUE);
light2 is the light I added. I'm not sure how the coords that point the light in a certain direction work. I need to know where they're pointing from before I can set where they are pointing to. Thanks for any help. [Edited by - LessBread on July 19, 2008 3:18:46 PM]

#### Share this post

##### Share on other sites
Advertisement
Quote:
 Original post by cNoobDirectional lights don't have a position, just a direction. It sounds like your wanting to use a point light in order to have a position and direction.This page describes several light types the fixed function pipeline provides

So if directional lights don't have a position, how do we define where it's pointing. Is it that one spot that's getting lit?

#### Share this post

##### Share on other sites
Think of a directional light like sunlight hitting a city. It comes from a particular direction but the position doesn't really matter.

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5
• Advertisement

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633682
• Total Posts
3013306
×

## Important Information

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

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!