|
This is a tutorial on how to fix the negative lighting bug which happens on some cards, after applying the colored lighting tutorial to your engine/source. Thanks to Ender it's fixed now. Open up gl_rsurf.c and replace the r_blendlightmaps with this function, new parts are in blue.
/*
================
R_BlendLightmaps
================
*/
void R_BlendLightmaps (void)
{
int i, j;
glpoly_t *p;
float *v;
glRect_t *theRect;
if (r_fullbright.value)
return;
if (!gl_texsort.value)
return;
glDepthMask (0); // don't bother writing Z
// Ender - Fix negative lighting... with negative lighting. Wee :)
if (gl_lightmap_format == GL_INTENSITY) {
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f (0,0,0,1);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} else {
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
}
// Ender - End
if (!r_lightmap.value)
{
glEnable (GL_BLEND);
}
for (i=0 ; i |