# My faces are too dark

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

## Recommended Posts

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

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

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

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

##### Share on other sites
Quote:
 Original post by matches81Of 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).

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

Also: Make sure your normals face into the room

//emijo

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

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

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

##### Share on other sites
Quote:
 Original post by SONBHow 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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 23
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
634779
• Total Posts
3019240
×