I am trying to add the contributions of two lights. What happens though is that nothing gets blend and I only see the result of one or the other. I actually get depth fighting, which really weird since and always use the same calls and matrices to do the transform.
I render all my scene to the depth buffer first, then disable depth write and use GL_EQUAL for depth test and go on with rendering the lighted objects.
I do diffuse by rendering N dot L in the alpha buffer and simply blending with the diffuse color.
This is the setup for a light shining on an object
glColorMask( false, false ,false, true ); { glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_CUBE_MAP_ARB); glBindTexture( GL_TEXTURE_CUBE_MAP, cubemaptexture) ; glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } { glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture( GL_TEXTURE_2D, bumpMap ); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGBA_ARB); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); } Draw();
{
glDisable(GL_TEXTURE_2D);glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_CUBE_MAP); }
//do the color pass glEnable(GL_BLEND); glBlendFunc(GL_DST_ALPHA,GL_ONE); glColorMask( true, true , true, false ); { glEnable(GL_TEXTURE_2D); glBindTexture( GL_TEXTURE_2D, diffuse ) ; glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } Draw(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND);
Blending does work properly when I am rendering differently.
If somebody could point something wrong or hint on something to look for, I would be quite happy.
[This message has been edited by Gorg (edited 02-04-2003).]
[This message has been edited by Gorg (edited 02-04-2003).]