Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

david_j_noah

Problem with spot lights and point lights

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

Hello, I am writing a Direct3D-application in C#. My Directional-Light is working fine and without problems. When using a spot-light or a point-light nothing happens. Here is the code: global.device.Lights[0].Diffuse = Color.White; global.device.Lights[0].Type = LightType.Directional; global.device.Lights[0].Direction = new Vector3(-3, -1, 3); global.device.Lights[0].Commit(); global.device.Lights[0].Enabled=false; // works fine when true global.device.Lights[1].Diffuse=Color.White; global.device.Lights[1].Type=LightType.Spot; global.device.Lights[1].InnerConeAngle=0.5f; global.device.Lights[1].OuterConeAngle=1.0f; global.device.Lights[1].Position=new Vector3(0.0f, 0.0f, -5.0f); global.device.Lights[1].Direction=new Vector3(0.0f, 0.0f, 1.0f); global.device.Lights[1].Falloff=1.0f; global.device.Lights[1].Commit(); global.device.Lights[1].Enabled = true; // Does not work Do you have any idea what is wrong?

Share this post


Link to post
Share on other sites
Advertisement
I have not touched lights much, but for point lights, you need to set your attenuation. Try light.attenuation1 = 0.45;

Run dbMon with the debug version of DirectX, it will tell you why lights don''t work.

Share this post


Link to post
Share on other sites
What are you shining the spotlight on? How many vertices are visible? Also, from your position and direction vectors, it looks like you''ll only be illuminating a wall/object in the XY plane. Also, you need to set the range value of the spotlight. The range is probably set to 0 and not showing up at all.

Chris

Share this post


Link to post
Share on other sites
Hi,

the range was the problem. Thanks!

I used it before but had some other problems and removed it again because I thought it made no difference!

Again, thanks for the help!

David

Share this post


Link to post
Share on other sites

  • 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!