Jump to content
  • Advertisement
Sign in to follow this  
frankypoo

lighting with FVF problems

This topic is 4864 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 trying to light a basic scene. I set up the lights once in my InitD3D() function with the following code: int numLights=0; VOID SetLight(float x, float y, float z, float intensity) { D3DLIGHT9 PointLight; ZeroMemory(&PointLight, sizeof(D3DLIGHT9)); PointLight.Type=D3DLIGHT_POINT; PointLight.Position=D3DXVECTOR3(x, y, z); PointLight.Diffuse=D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); PointLight.Range=intensity*100.0f; g_pd3dDevice->SetLight(numLights, &PointLight); g_pd3dDevice->LightEnable(numLights++, TRUE); } I set up two lights, which both succeed in turning on and lighting the scene... but they turn everything pure white, and when I move my character past the light the shadow is a definite line that separates white from black. Before this function was working correctly, I forgot to set PointLight.Type=D3DLIGHT_POINT, and it actually lit my scene the way I wanted it to: by shading things properly and according to their material, rather than turning everything white and without gradient. I couldn't manipulate this light, however, since it's something of a DX default fall-back, so I can't resort to that. I'm wondering, I only set these lights up during initialization. Do i need to set the lights each DrawSubset() call in Render()?

Share this post


Link to post
Share on other sites
Advertisement
The default light type, if you don't specify one, is a D3DLIGHT_DIRECTIONAL. Directional lights are good for full-scene lighting, for simulating the sun or something.

I'm not sure why your light is turning everything pure white. However, your second problem sounds like you haven't set the attenuation of the light. Try setting the .Fallof member to 1 and the .Attenuation0 member to 1 as well. It'll make the light intensity fall off gradually from full brightness at the light source to nothing at the edge of its range.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Sure :)

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!