Skip to main content
gamedev.net
🔒 Locked

[MDX]Lighting problem

Started by Fadiii Jul 7, 2006 at 12:56 PM 1 replies 650+ views
Original Post
Fadiii
Fadiii
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;

Fadiii
Fadiii
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...
jollyjeffers
jollyjeffers
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.