Jump to content
  • Advertisement
Sign in to follow this  
WhoCares357

Directional lights?

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


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


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!