Sign in to follow this  
MourningDew

Another Lighting Issue

Recommended Posts

Now that I have my normals sorted out, I am having another lighting lighting issue. I have defined a cube for a house, and translated, scaled, and rotated it several times so that I have two rows of houses, facing one another, with a largish gap in the middle of them (ala a street). I also have a directional light which "rotates" about the z axis (like the sun) The rows of houses go along the z axis (i.e. into and out of the screen) My issue is that the rows of houses will not light up properly...The backs of one lot (the ones I am NOT rotating) and the fronts of the others (The ones I AM rotating) are always dark. All surfaces that refuse to be lit are facing the same direction...WTF IS GOING ON?!?!?! This is how I am changing the direction of the sun: float theta = timeGetTime()/2000.0f; //Create and setup the sun D3DLIGHT9 sun; ZeroMemory(&sun,sizeof(D3DLIGHT9)); sun.Type = D3DLIGHT_DIRECTIONAL; sun.Diffuse.r = 1.0f; sun.Diffuse.g = 1.0f; sun.Diffuse.b = 1.0f; //Give the sun a normalised direction D3DXVECTOR3 sunDir; sunDir = D3DXVECTOR3(-cosf(theta),-sinf(theta),0.0f); D3DXVec3Normalize((D3DXVECTOR3*)&sun.Direction, &sunDir); sun.Range = 1000.0f; //Turn on the sun!! pd3dDevice->SetLight(0, &sun); pd3dDevice->LightEnable(0, TRUE); pd3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE); pd3dDevice->SetRenderState(D3DRS_AMBIENT, 0x00202020);

Share this post


Link to post
Share on other sites
sounds a lot like the normals aren't being transformed if they stay dark on the same side regardless of the light direction. if you're using the pipeline to do T+L, transformation of normals shouldn't be a problem. did you set a material? did you scale vertices without normalizing normals? (if so use the render state NORMALIZE_NORMALS )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this