• 11
• 9
• 10
• 9
• 10

# Ugly Lighting

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

## Recommended Posts

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.

##### Share on other sites
Set D3DRS_NORMALIZENORMALS to true.

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