Jump to content
  • Advertisement
Sign in to follow this  
Klaatu

OpenGL Two-sided lighting for DirectX

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

OpenGL uses glLightModelf to specifiy two sided lighting of polygons. Is there an equivalent for DirectX? Currently, I've had to recalculate face normals if I am rotating a primitive. This can be quite time consuming if it's a surface model with thousands of polygons.

Share this post


Link to post
Share on other sites
Advertisement
Set your CULLMODE to
D3DCULL_NONE using the SetRenderState function. This will cause all triangles to render back and front.

device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

EDIT* Not sure if the above is what you are looking for. Haven't tested if turning off culling will affect the lighting on the backfaces. I am assuming that the lighting will affect the triangle normally, but this may not be the case. I'm not in a place where I can test it so, I hope it helps :)

Webby

Share this post


Link to post
Share on other sites
Webby:
Thanks for the reply. I'm already setting the CULLMODE off. It does not appear to affect the lighting. Polygons that are not facing the light source appear as dark.

Share this post


Link to post
Share on other sites
If I understand you correctly, you want to light each side differently.

If that is the case, then there is no way to avoid drawing everything twice -- once for each side. You normally would have to reverse all the normals, but if you are using only direction and ambient lights, then you can change the direction of the lights when drawing the opposite side instead. Note that if you draw twice, you have to turn the culling back on and switch it for each side.

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!