Ugly Lighting

Started by
3 comments, last by psycho_svk 16 years, 10 months ago
Hello, I am currently experiencing some very ugly lighting using Direct3D 9. I am using a D3DTS_WORLD transform to both transform and SCALE a mesh. I capitalize the world scale because that is where my ugly lighting is showing up.

Here is the mesh as it is lit when it is scaled (notice the sort of jagged lighting on the character's back):

Here is the mesh not scaled:

The lighting is much more smooth when the world transform does not scale the mesh.

Here is what I'm doing to set up the world transform:


D3DMATRIX matScale, matTrans;
D3DXMatrixScaling(&matScale, SCALE_FACTOR, SCALE_FACTOR, SCALE_FACTOR);
D3DXMatrixMultiply(&matTrans, &matScale, &m_matOrient);
m_pDevice->SetTransform(D3DTS_WORLD, &matTrans);

Any help as to what my options are to get the lighting to look more uniform when the mesh is scaled would be appreciated.

Peace Out.

Advertisement
Set D3DRS_NORMALIZENORMALS to true.
Your normals are getting scaled along with the model, causing them to no longer be normalized.

You'll need to tell DX to renormalize them (at a small performance cost) using:
device->SetRenderState(D3DRS_NORMALIZENORMALS, true);

Hope this helps.

[EDIT] Too slow. :(
Sirob Yes.» - status: Work-O-Rama.
Thanks guys, that works, the mesh looks a lot better.


Peace Out.

after remembering OpenGL FAQ - 18.090 Why is the lighting incorrect after I scale my scene to change its size?

i have googled this for you:
DX3D - My world matrix scales an item, and the normals are scaled as well. How can I prevent this from affecting my lighting?

edit: even slower :)

This topic is closed to new replies.

Advertisement