Jump to content
  • Advertisement
Sign in to follow this  
Fadiii

[MDX]Lighting problem

This topic is 4337 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 feel silly,but the ambient light is not working in my scene,and when enabling the directional light I have a dark scene except the main character. Here is the scene with ambient light only.
device.RenderState.Ambient=Color.White;
device.RenderState.Lighting=true;

render result Here is the scene with directional light enabled
device.Lights[0].Type = LightType.Directional;
device.Lights[0].Direction = new Vector3(0.0f, -1.0f, 1.0f);
device.Lights[0].Diffuse = Color.White;
device.Lights[0].Range = 10000.0f;
device.Lights[0].Enabled = true;

Share this post


Link to post
Share on other sites
Advertisement
No posts at all,anyway I solved it, the problem was that I scaled the scene not the character, so the normals of all the meshs affected by this operation and need to be normalized again.
The solution is to use the NormalizeNormal option in render state after transforming the mesh.

device.RenderState.NormalizeNormals=true;

So scaling can affect lighting...

Share this post


Link to post
Share on other sites
Quote:
Original post by Fadiii
device.RenderState.NormalizeNormals=true;

So scaling can affect lighting...
Yes, scaling affects normals - for lighting calculations to be correct then normals have to be unit-length. Typically if they're shorter you get dull/darker lighting and if they're longer you get brighter lighting.

Just be careful about the NormalizeNormals state - only use it if you have to, as renormalizing a vector isn't a free operation...

hth
Jack

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!