Directional lights?

Started by
2 comments, last by Dancin_Fool 15 years, 9 months ago
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]
Advertisement
Directional 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
Quote:Original post by cNoob
Directional 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?
Think of a directional light like sunlight hitting a city. It comes from a particular direction but the position doesn't really matter.

This topic is closed to new replies.

Advertisement