# Lighting issue?

This topic is 3538 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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;
dev->SetLight(0, &light);
dev->LightEnable(0, true);

##### Share on other sites
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 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.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002274
×