My faces are too dark

Started by
12 comments, last by Flimflam 18 years, 4 months ago
Hi! My scene has one point-light source and a mesh. The problem is: the light is in the middle of the mesh (it is a room) and the walls which are closer to the light are darker than the walls far away. The normals of the mesh have the same length. How can I fix this problem? Any suggestions? Thanx in advance! SONB
Advertisement
Normals shouldn't have a length.. They should be normalized to unit vectors (0.0 to 1.0).

Could you show us your Light initialization? And activation (enabling)?
Of course normals do have a length, as they are vectors. In most cases normals will have a length of 1, which would make them normalized vectors (or unit vectors) and will mean that their components would be in the interval [0.0, 1.0], obviously.
I'm not quit sure ,but it maybe cause of the dirction of normals.Try put your light out of the room ,if it looks right that's it.
Try to change the cull mode to D3DCULL_CW,by using pdev->SetRenderState( D3DRS_CULLMODE,D3DCULL_CW)
Quote:Original post by matches81
Of course normals do have a length, as they are vectors. In most cases normals will have a length of 1, which would make them normalized vectors (or unit vectors) and will mean that their components would be in the interval [0.0, 1.0], obviously.


But in this context, I think when he's saying that he's not sure if the lengths of the normals aren't correct, he is not talking about the lengths along the axes but the length of the vector. Since the length of the vector isn't used when dealing with normals I think it's safe to say that normals indicate a direction (angle and maybe length along each axis) and not a distance (length).
@Pipo DeClown:

When calculating lighting on a face using the normal of the face (or vertices) the vector length does matter. The normals must be unit length, else lighting will be flawed.

@SONB:

How are your normals calculated? Are they normals to the vertices themselfes or normals to the surface the vertices create (in this case walls, floor and ceiling)? In the latter case, if the lightsource is close to one wall the angle between the light and the vertices will be big, and the vertices will therefor be dark, leading to a darker surface then expected.

[Edit]

Also: Make sure your normals face into the room

//emijo
Emil Jonssonvild
Quote:Original post by cannonicus
@Pipo DeClown:

When calculating lighting on a face using the normal of the face (or vertices) the vector length does matter. The normals must be unit length, else lighting will be flawed.

@SONB:

How are your normals calculated? Are they normals to the vertices themselfes or normals to the surface the vertices create (in this case walls, floor and ceiling)? In the latter case, if the lightsource is close to one wall the angle between the light and the vertices will be big, and the vertices will therefor be dark, leading to a darker surface then expected.

[Edit]

Also: Make sure your normals face into the room

//emijo


If you look at the Original Post, you can see he uses "same length" to describe his normals. To me it seems that he does not know that normals are unit vectors. I wanted to inform him that normals may have lengths but those aren't important since they are always the same (1).

So basically what I tried to say was that normals are used to hold directions and not distances. Maybe I didn't explain myself well enough.
Wow, thanx a lot for your replies!

Well, the normals are all normalized and face into the room and they are normals to the surface the vertices create. How can I change the way they are calculated?

I made the mesh in Maya, if that helps.


SONB
Are you using the fixed-function pipeline, and are you doing any scaling when rendering? If so, try setting D3DRS_NORMALIZENORMALS to TRUE and see if it sorts things out [smile]

It's a subtle bug that's caught me out a few times over the years... but under the FF the scaling of the world matrix affects the length of the normals, which feeds into the calculations. Reducing the size of your world gives darker lighting and increasing the size makes things a whole lot brighter.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by SONB
How can I change the way they are calculated?

If it's being loaded in to an ID3DXMesh container, you could look into the D3DXComputeNormals() function.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement