Jump to content
  • Advertisement
Sign in to follow this  
MourningDew

Another Lighting Issue

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

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
Advertisement
Do you have materials applied to your meshes? It looks like you have the lighting set up right and everthing but lighting calculations need a light and a material to find the final color of your polygon.

Material tutorial

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
Hey

Yes, a material is set, I' ve already overcome *that* hurdle hehehe...I will try the "NORMALIZE NORMALS" thing, because I'm pretty sure that I'm using the pipeline for my Transformations...

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!