Sign in to follow this  

Lighting confusion..

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

Hello there! I seem to have gotten myself a little confused, and I was wondering if anyone could help clarify things for me. I've been practicing displaying a textured 3D cube (one of the examples in Programming RolePlaying Games in DirectX), and upon my first build i was presented with everything I expected, except for a missing texture (the cube was black). Looking through Jim Adams' code he uses the following line, which fixes things: g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); Just wondering why I need to set the light stream to False, when i never set it to True in the first place. Also, why is this line not necessary in his example of a textured 2D square? Thankyou in advance for any help!

Share this post


Link to post
Share on other sites
I'm not familiar with Direct3D, but I would think it's probably due to absence of properly-positioned lights in the scene. Set up some ambient lighting, then you should no longer have to turn off the lighting to see anything.

I can't begin to think about the second question without looking at the code.

Share this post


Link to post
Share on other sites
You have to set it to false, because it's true by default:

Quote:

D3DRS_LIGHTING
TRUE to enable Direct3D lighting, or FALSE to disable it. The default value is TRUE. Only vertices that include a vertex normal are properly lit; vertices that do not contain a normal employ a dot product of 0 in all lighting calculations.


(from the DirectX SDK documentation)

Share this post


Link to post
Share on other sites

This topic is 4204 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.

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