Jump to content
  • Advertisement
Sign in to follow this  
akaitora

Lighting issue?

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

Hi. I am using Windows VISTA on a 64-bit machine. I am using DirectX 9.0c/C++/ and Visual Studio 2005. When running my game on windows vista, all my meshes and their respective materials appear to be rendered correctly. However when I run it on a windows xp machine, all my meshes appear black. If I set the emissive property of my material equal to my diffuse, then I can see the colors on the xp machine. However I lose my shading by doing this so this isn't a really good solution. Because changing the emissive property of my material seems to atlest show the right color on the xp machine, I am thinking that I am probably not initializing my light correctly. Can you please review my light initialization snippet and see if I am doing anything wrong? Thanks!
ZeroMemory(&light, sizeof(D3DLIGHT9));
light.Type = D3DLIGHT_SPOT;
light.Ambient =  D3DXCOLOR(1.0f,1.0f,1.0f,1.0f) * 0.4f;
light.Diffuse = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);
light.Specular = D3DXCOLOR(255,255.0f,255.0f,1.0f) * 0.6f;
light.Direction = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
light.Position = D3DXVECTOR3(0.0f,3.0f,-5.0f);
light.Range = 90.0f;
light.Attenuation0 = 1;
light.Attenuation1 = 0;
light.Attenuation2 = 0;
light.Phi = D3DXToRadian(180.0f);
light.Theta = D3DXToRadian(90.0f);
dev->SetLight(0, &light);
dev->LightEnable(0, true);

Share this post


Link to post
Share on other sites
Advertisement
It seems when I change my light type from d3dlight_spot to d3dlight_point, the meshes appear correctly on both my vista and xp machines. That is great news for me as it now works but I would like to understand why this happened.

Share this post


Link to post
Share on other sites
You don't appear to be setting the Falloff parameter at all, apart from via ZeroMemory(). Does setting it to say 1.0 help?

In addition since the maximum allowable value for Phi is pi (180 degrees) it's possible you're getting a maths inaccuracy in the conversion that is pushing it just over pi on Vista.

I'd recommend checking the return values from the SetLight and LightEnable calls, one of them probably fails on Vista. The documentation at http://msdn.microsoft.com/en-us/library/bb172566(VS.85).aspx may also be helpful.

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!