Jump to content
  • Advertisement
Sign in to follow this  
Helderash

Lighting confusion..

This topic is 4512 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
Advertisement
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
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!