Sign in to follow this  
Klaatu

OpenGL Two-sided lighting for DirectX

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
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

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