• Advertisement

Archived

This topic is now archived and is closed to further replies.

Direct3D8 Lighting dependant of triangle size?

This topic is 5679 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 am programming a simple terrain engine with Direct3D lighting. It works well, but I wanted to scale the terrain by factor = 2 or 3. So I multiply the vertex position vectors by factor. But now the terrain is much too bright. I found out that I have to divide the light brightness by (factor*factor)! Why? Oregon Ghost Wenn NULL besonders gross ist, ist es fast schon wie ein bisschen eins ;c) if NULL is very big, it is almost like a little one.

Share this post


Link to post
Share on other sites
Advertisement
Make sure you are not scaling your normals. Normals should remain Unit length, where the magnitude always equals 1.0

Share this post


Link to post
Share on other sites
That''s it, thanks ;c)

But why? I thought the normal describes a direction, and not a scalar.

Oregon Ghost

Share this post


Link to post
Share on other sites
You can choose either way. Call this function to enable D3D to normalize the normals.
IDirect3DDevice8::SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );

Share this post


Link to post
Share on other sites
It does describe a direction, but if you do do a dot product using a none unit length normal, you results will be scaled accordingly. (Which is why things got x times brighter when you scaled the normal by x).

You can use
IDirect3DDevice8::SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );

But it is more efficent to only calculate unit length normals once, not every frame, for obvious speed reasons.

Share this post


Link to post
Share on other sites
Hmm... must have been a math lesson where I wasn''t really there...

But I will normalize the normals on my own ;c)

Share this post


Link to post
Share on other sites
Yes, or you could have the card do it for you
SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);

T

--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites

  • Advertisement