New cvar: gl_colorlights, default 1 for GL_RBGA lightmaps, set to 0 for

GL_LUMINANCE lightmaps.  This is a CVAR_ROM.
This commit is contained in:
Joseph Carter 2000-05-25 04:16:41 +00:00
parent ab1aadfe64
commit 08ae0f5305
4 changed files with 61 additions and 81 deletions

View file

@ -122,14 +122,14 @@ void CL_NewDlight (int key, float x, float y, float z, float radius, float time,
{ {
default: default:
case 0: case 0:
dl->color[0] = 0.2; dl->color[0] = 0.4;
dl->color[1] = 0.1; dl->color[1] = 0.2;
dl->color[2] = 0.05; dl->color[2] = 0.05;
break; break;
case 1: // blue case 1: // blue
dl->color[0] = 0.05; dl->color[0] = 0.05;
dl->color[1] = 0.05; dl->color[1] = 0.05;
dl->color[2] = 0.3; dl->color[2] = 0.5;
break; break;
case 2: // red case 2: // red
dl->color[0] = 0.5; dl->color[0] = 0.5;
@ -139,7 +139,7 @@ void CL_NewDlight (int key, float x, float y, float z, float radius, float time,
case 3: // purple case 3: // purple
dl->color[0] = 0.5; dl->color[0] = 0.5;
dl->color[1] = 0.05; dl->color[1] = 0.05;
dl->color[2] = 0.4; dl->color[2] = 0.5;
break; break;
} }
} }

View file

@ -1051,7 +1051,6 @@ void CL_MuzzleFlash (void)
dl->color[0] = 0.2; dl->color[0] = 0.2;
dl->color[1] = 0.1; dl->color[1] = 0.1;
dl->color[2] = 0.05; dl->color[2] = 0.05;
dl->color[3] = 0.7;
} }

View file

@ -259,14 +259,9 @@ void CL_ParseTEnt (void)
dl->radius = 350; dl->radius = 350;
dl->die = cl.time + 0.5; dl->die = cl.time + 0.5;
dl->decay = 300; dl->decay = 300;
// dl->color[0] = 0.2; dl->color[0] = 0.86;
// dl->color[1] = 0.1; dl->color[1] = 0.31;
// dl->color[2] = 0.05; dl->color[2] = 0.24;
// dl->color[3] = 0.7;
dl->color[0] = 0.8;
dl->color[1] = 0.2;
dl->color[2] = 0.8;
dl->color[3] = 1;
// sound // sound
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);

View file

@ -4,6 +4,7 @@
surface-related refresh code surface-related refresh code
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 2000 Joseph Carter <knghtbrd@debian.org>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
@ -63,11 +64,13 @@ int skytexturenum;
#endif #endif
int lightmap_bytes; // 1, 2, or 4 int lightmap_bytes; // 1 or 4
int lightmap_textures; int lightmap_textures;
unsigned blocklights[18*18]; unsigned blocklights[4][18*18];
cvar_t *gl_colorlights;
#define BLOCK_WIDTH 128 #define BLOCK_WIDTH 128
#define BLOCK_HEIGHT 128 #define BLOCK_HEIGHT 128
@ -110,6 +113,7 @@ void R_AddDynamicLights (msurface_t *surf)
int i; int i;
int smax, tmax; int smax, tmax;
mtexinfo_t *tex; mtexinfo_t *tex;
dlight_t *dl;
smax = (surf->extents[0]>>4)+1; smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1; tmax = (surf->extents[1]>>4)+1;
@ -156,7 +160,13 @@ void R_AddDynamicLights (msurface_t *surf)
else else
dist = td + (sd>>1); dist = td + (sd>>1);
if (dist < minlight) if (dist < minlight)
blocklights[t*smax + s] += (rad - dist)*256; {
dl = &cl_dlights[lnum];
blocklights[0][t*smax + s] += (rad - dist)*(dl->color[0]*256);;
blocklights[1][t*smax + s] += (rad - dist)*(dl->color[1]*256);;
blocklights[2][t*smax + s] += (rad - dist)*(dl->color[2]*256);;
blocklights[3][t*smax + s] += (rad - dist)*256;
}
} }
} }
} }
@ -178,7 +188,7 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
byte *lightmap; byte *lightmap;
unsigned scale; unsigned scale;
int maps; int maps;
unsigned *bl; unsigned *rbl, *gbl, *bbl, *bl;
surf->cached_dlight = (surf->dlightframe == r_framecount); surf->cached_dlight = (surf->dlightframe == r_framecount);
@ -191,13 +201,19 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
if (/* r_fullbright->value || */ !cl.worldmodel->lightdata) if (/* r_fullbright->value || */ !cl.worldmodel->lightdata)
{ {
for (i=0 ; i<size ; i++) for (i=0 ; i<size ; i++)
blocklights[i] = 255*256; blocklights[0][i] =
blocklights[1][i] =
blocklights[2][i] =
blocklights[3][i] = 255*256;
goto store; goto store;
} }
// clear to no light // clear to no light
for (i=0 ; i<size ; i++) for (i=0 ; i<size ; i++)
blocklights[i] = 0; blocklights[0][i] =
blocklights[1][i] =
blocklights[2][i] =
blocklights[3][i] = 0;
// add all the lightmaps // add all the lightmaps
if (lightmap) if (lightmap)
@ -207,7 +223,12 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
scale = d_lightstylevalue[surf->styles[maps]]; scale = d_lightstylevalue[surf->styles[maps]];
surf->cached_light[maps] = scale; // 8.8 fraction surf->cached_light[maps] = scale; // 8.8 fraction
for (i=0 ; i<size ; i++) for (i=0 ; i<size ; i++)
blocklights[i] += lightmap[i] * scale; {
blocklights[0][i] += lightmap[i] * scale;
blocklights[1][i] += lightmap[i] * scale;
blocklights[2][i] += lightmap[i] * scale;
blocklights[3][i] += lightmap[i] * scale;
}
lightmap += size; // skip to next lightmap lightmap += size; // skip to next lightmap
} }
@ -217,41 +238,34 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
// bound, invert, and shift // bound, invert, and shift
store: store:
switch (gl_lightmap_format) if (gl_colorlights->value)
{ {
case GL_RGBA:
stride -= (smax<<2); stride -= (smax<<2);
bl = blocklights; rbl = blocklights[0];
gbl = blocklights[1];
bbl = blocklights[2];
bl = blocklights[3];
for (i=0 ; i<tmax ; i++, dest += stride) for (i=0 ; i<tmax ; i++, dest += stride)
{
for (j=0 ; j<smax ; j++) for (j=0 ; j<smax ; j++)
{ {
t = *rbl++;
dest[0] = 255 - min(t >> 7, 255);
t = *gbl++;
dest[1] = 255 - min(t >> 7, 255);
t = *bbl++;
dest[2] = 255 - min(t >> 7, 255);
t = *bl++; t = *bl++;
t >>= 7; dest[3] = 255 - min(t >> 7, 255);
t = min(t, 255);
dest[3] = 255-t;
dest += 4; dest += 4;
} }
} } else {
break; bl = blocklights[3];
case GL_ALPHA:
case GL_LUMINANCE:
case GL_INTENSITY:
bl = blocklights;
for (i=0 ; i<tmax ; i++, dest += stride) for (i=0 ; i<tmax ; i++, dest += stride)
{
for (j=0 ; j<smax ; j++) for (j=0 ; j<smax ; j++)
{ {
t = *bl++; t = *bl++;
t >>= 7; dest[j] = 255 - min(t >> 7, 255);
if (t > 255)
t = 255;
dest[j] = 255-t;
} }
}
break;
default:
Sys_Error ("Bad lightmap format");
} }
} }
@ -416,7 +430,7 @@ void R_DrawSequentialPoly (msurface_t *s)
speedscale = realtime*16; speedscale = realtime*16;
speedscale -= (int)speedscale; speedscale -= (int)speedscale;
EmitSkyPolys (s); EmitSkyPolys (s);
if (gl_lightmap_format == GL_LUMINANCE) if (!gl_colorlights->value)
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glDisable (GL_BLEND); glDisable (GL_BLEND);
@ -712,14 +726,7 @@ void R_BlendLightmaps (void)
glDepthMask (0); // don't bother writing Z glDepthMask (0); // don't bother writing Z
if (gl_lightmap_format == GL_LUMINANCE) glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
else 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);
}
if (!r_lightmap->value) if (!r_lightmap->value)
{ {
@ -777,13 +784,9 @@ void R_BlendLightmaps (void)
} }
glDisable (GL_BLEND); glDisable (GL_BLEND);
if (gl_lightmap_format == GL_LUMINANCE)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Return to normal blending --KB
else if (gl_lightmap_format == GL_INTENSITY) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
{
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4f (1,1,1,1);
}
glDepthMask (1); // back to normal Z buffering glDepthMask (1); // back to normal Z buffering
} }
@ -1650,31 +1653,16 @@ void GL_BuildLightmaps (void)
texture_extension_number += MAX_LIGHTMAPS; texture_extension_number += MAX_LIGHTMAPS;
} }
gl_lightmap_format = GL_LUMINANCE; gl_colorlights = Cvar_Get ("gl_colorlights", "1", CVAR_ROM,
if (COM_CheckParm ("-lm_1")) "Whether to use RGBA lightmaps or not");
gl_lightmap_format = GL_LUMINANCE;
if (COM_CheckParm ("-lm_a"))
gl_lightmap_format = GL_ALPHA;
if (COM_CheckParm ("-lm_i"))
gl_lightmap_format = GL_INTENSITY;
if (COM_CheckParm ("-lm_2"))
gl_lightmap_format = GL_RGBA4;
if (COM_CheckParm ("-lm_4"))
gl_lightmap_format = GL_RGBA;
switch (gl_lightmap_format) if (gl_colorlights->value)
{ {
case GL_RGBA: gl_lightmap_format = GL_RGBA;
lightmap_bytes = 4; lightmap_bytes = 4;
break; } else {
case GL_RGBA4: gl_lightmap_format = GL_LUMINANCE;
lightmap_bytes = 2;
break;
case GL_LUMINANCE:
case GL_INTENSITY:
case GL_ALPHA:
lightmap_bytes = 1; lightmap_bytes = 1;
break;
} }
for (j=1 ; j<MAX_MODELS ; j++) for (j=1 ; j<MAX_MODELS ; j++)
@ -1691,10 +1679,8 @@ void GL_BuildLightmaps (void)
GL_CreateSurfaceLightmap (m->surfaces + i); GL_CreateSurfaceLightmap (m->surfaces + i);
if ( m->surfaces[i].flags & SURF_DRAWTURB ) if ( m->surfaces[i].flags & SURF_DRAWTURB )
continue; continue;
//#ifndef QUAKE2
if ( m->surfaces[i].flags & SURF_DRAWSKY ) if ( m->surfaces[i].flags & SURF_DRAWSKY )
continue; continue;
//#endif
BuildSurfaceDisplayList (m->surfaces + i); BuildSurfaceDisplayList (m->surfaces + i);
} }
} }