Jump to content
  • Advertisement
Sign in to follow this  
SONB

My faces are too dark

This topic is 4602 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

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 this post


Link to post
Share on other sites
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)?

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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).

Share this post


Link to post
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.

[Edit]

Also: Make sure your normals face into the room

//emijo

Share this post


Link to post
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.

[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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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

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!