Hydrael
05-07-2006, 11:36 PM
Hello everyone,
I've recently implemented a per Pixel lighting shader for multiple lights within my engine. At the moment, it's one rendering pass per light in view. Each pass, the scene is rendered with texturing disabled and blendmode (GL_ONE,GL_ONE) active (additive blending). After that's done, I have all the lighting information for the active frame.
That result will then be multiplied (GL_ZERO, GL_SRC_COLOR) with another pass with texturing enabled and lighting disabled to create the final image.
The problem I now have, is that I do get some Z-Order issues (or is it transparency due to the blending?). Here is what I mean (the right image shows the same spot with normal fixed function pipeline lighting (single pass)):
http://img271.imageshack.us/img271/9079/blending17tv.jpg
Here is the responsible piece of code from my rendering loop:
glEnable(GL_LIGHT0);
glBlendFunc(GL_ONE,GL_ONE);
glEnable(GL_BLEND);
m_pPerPixelShader->Activate();
for(int i=0;i<m_iActiveLightCount;i++)
{ //Lighting passes
ActivatePerPixelLight(i);
RenderBruteForce(RENDERLIGHTING);
}
m_pPerPixelShader->Deactivate();
glDisable(GL_LIGHT0);
glBlendFunc(GL_ZERO,GL_SRC_COLOR);
glEnable(GL_TEXTURE_2D);
RenderBruteForce(RENDERTEXTURED); //Textured pass
glDisable(GL_BLEND);
I'm using DepthFunc(GL_LEQUAL), because nothing else seems to work for the additive blending.
Can anyone spot, what I'm doing wrong?
Thanks in advance
Chris
I've recently implemented a per Pixel lighting shader for multiple lights within my engine. At the moment, it's one rendering pass per light in view. Each pass, the scene is rendered with texturing disabled and blendmode (GL_ONE,GL_ONE) active (additive blending). After that's done, I have all the lighting information for the active frame.
That result will then be multiplied (GL_ZERO, GL_SRC_COLOR) with another pass with texturing enabled and lighting disabled to create the final image.
The problem I now have, is that I do get some Z-Order issues (or is it transparency due to the blending?). Here is what I mean (the right image shows the same spot with normal fixed function pipeline lighting (single pass)):
http://img271.imageshack.us/img271/9079/blending17tv.jpg
Here is the responsible piece of code from my rendering loop:
glEnable(GL_LIGHT0);
glBlendFunc(GL_ONE,GL_ONE);
glEnable(GL_BLEND);
m_pPerPixelShader->Activate();
for(int i=0;i<m_iActiveLightCount;i++)
{ //Lighting passes
ActivatePerPixelLight(i);
RenderBruteForce(RENDERLIGHTING);
}
m_pPerPixelShader->Deactivate();
glDisable(GL_LIGHT0);
glBlendFunc(GL_ZERO,GL_SRC_COLOR);
glEnable(GL_TEXTURE_2D);
RenderBruteForce(RENDERTEXTURED); //Textured pass
glDisable(GL_BLEND);
I'm using DepthFunc(GL_LEQUAL), because nothing else seems to work for the additive blending.
Can anyone spot, what I'm doing wrong?
Thanks in advance
Chris