Two-sided lighting for DirectX
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.
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
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
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement