Hello. So I’m trying to figure out how to have stencil shadows in my project with multiple lights. I’m trying to do it like this: http://lwjgl.org/forum/index.php?topic=5203.0 but in 3D.
This is my code:
for (Light light : lights) {
glColorMask(false, false, false, false);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glCallList(displayList);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glStencilFunc(GL_EQUAL, 0, 1);
glColorMask(true, true, true, true);
Shader.lightShader.enable();
updateUniforms();
light.updateUniforms(normalMatrix);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glCallList(displayList);
glDisable(GL_BLEND);
Shader.lightShader.disable();
glClear(GL_STENCIL_BUFFER_BIT);
}
Previously, I would render my scene like this:
Shader.lightShader.enable();
updateUniforms();
glEnable(GL_BLEND);
for (int i = 0; i < lights.size(); i++) {
Light light = lights.get(i);
light.quadraticAttenuation = 1f / lights.size();
light.updateUniforms(normalMatrix);
if (i > 0) glBlendFunc(GL_ONE, GL_ONE);
glCallList(displayList);
}
glDisable(GL_BLEND);
Shader.lightShader.disable();
“displayList” contains all of the objects in my scene. Could anyone give some help? Cheers.