Brightness controls (brightness, contrast) and gl_lightmode cvar.

This commit is contained in:
Forest Hale 2000-07-02 05:16:10 +00:00
parent d9557428f2
commit 906ab864c2
8 changed files with 289 additions and 130 deletions

View file

@ -62,6 +62,7 @@ void LoadTGA (FILE *fin);
extern byte *host_basepal; extern byte *host_basepal;
extern unsigned char d_15to8table[65536]; extern unsigned char d_15to8table[65536];
extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor; extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor;
extern qboolean lighthalf;
cvar_t *gl_nobind; cvar_t *gl_nobind;
cvar_t *gl_max_size; cvar_t *gl_max_size;
@ -71,6 +72,9 @@ cvar_t *gl_constretch;
cvar_t *gl_conalpha; cvar_t *gl_conalpha;
cvar_t *gl_conspin; cvar_t *gl_conspin;
cvar_t *cl_verstring; cvar_t *cl_verstring;
cvar_t *gl_lightmode; // LordHavoc: lighting mode
cvar_t *brightness; // LordHavoc: brightness multiplier
cvar_t *contrast; // LordHavoc: contrast scaler
extern byte *draw_chars; // 8*8 graphic characters extern byte *draw_chars; // 8*8 graphic characters
qpic_t *draw_disc; qpic_t *draw_disc;
@ -389,6 +393,8 @@ void Draw_TextureMode_f (void)
} }
} }
extern void glrmain_init();
extern void glrsurf_init();
/* /*
=============== ===============
Draw_Init Draw_Init
@ -398,6 +404,13 @@ void Draw_Init (void)
{ {
int i; int i;
// LordHavoc: lighting mode
gl_lightmode = Cvar_Get("gl_lightmode", "1", CVAR_ARCHIVE,
"Lighting mode (0 = GLQuake style, 1 = new style)");
brightness = Cvar_Get("brightness", "1", CVAR_ARCHIVE,
"Brightness");
contrast = Cvar_Get("contrast", "1", CVAR_ARCHIVE,
"contrast");
gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_NONE, gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_NONE,
"whether or not to inhibit texture binding"); "whether or not to inhibit texture binding");
gl_max_size = Cvar_Get("gl_max_size", "1024", CVAR_NONE, gl_max_size = Cvar_Get("gl_max_size", "1024", CVAR_NONE,
@ -421,6 +434,11 @@ void Draw_Init (void)
!strncasecmp ((char *)gl_renderer, "Mesa",4)) !strncasecmp ((char *)gl_renderer, "Mesa",4))
Cvar_Set (gl_max_size, "256"); Cvar_Set (gl_max_size, "256");
// LordHavoc: 3DFX's dithering has terrible artifacting when using lightmode 1
if (!strncasecmp ((char *)gl_renderer, "3dfx",4))
Cvar_Set (gl_lightmode, "0");
lighthalf = gl_lightmode->value != 0; // to avoid re-rendering all lightmaps on first frame
Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f); Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f);
// load the console background and the charset // load the console background and the charset
@ -452,6 +470,10 @@ void Draw_Init (void)
// //
draw_disc = Draw_PicFromWad ("disc"); draw_disc = Draw_PicFromWad ("disc");
draw_backtile = Draw_PicFromWad ("backtile"); draw_backtile = Draw_PicFromWad ("backtile");
// LordHavoc: call init code for other GL renderer modules;
glrmain_init();
glrsurf_init();
} }
@ -487,7 +509,10 @@ void Draw_Character8 (int x, int y, int num)
glBindTexture (GL_TEXTURE_2D, char_texture); glBindTexture (GL_TEXTURE_2D, char_texture);
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (fcol, frow); glTexCoord2f (fcol, frow);
glVertex2f (x, y); glVertex2f (x, y);
@ -542,7 +567,10 @@ void Draw_Crosshair(void)
y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->value; y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->value;
pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value]; pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value];
glColor4ubv ( pColor ); if (lighthalf)
glColor4ub((byte) ((int) pColor[0] >> 1),(byte) ((int) pColor[1] >> 1), (byte) ((int) pColor[2] >> 1), pColor[3]);
else
glColor4ubv(pColor);
glBindTexture (GL_TEXTURE_2D, cs_texture); glBindTexture (GL_TEXTURE_2D, cs_texture);
glBegin (GL_QUADS); glBegin (GL_QUADS);
@ -587,7 +615,10 @@ void Draw_Pic (int x, int y, qpic_t *pic)
if (scrap_dirty) if (scrap_dirty)
Scrap_Upload (); Scrap_Upload ();
gl = (glpic_t *)pic->data; gl = (glpic_t *)pic->data;
glColor3f (0.4, 0.4, 0.4); if (lighthalf)
glColor3f(0.4,0.4,0.4);
else
glColor3f(0.8,0.8,0.8);
glBindTexture (GL_TEXTURE_2D, gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (gl->sl, gl->tl); glTexCoord2f (gl->sl, gl->tl);
@ -613,7 +644,10 @@ void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
if (scrap_dirty) if (scrap_dirty)
Scrap_Upload (); Scrap_Upload ();
gl = (glpic_t *)pic->data; gl = (glpic_t *)pic->data;
glColor4f (0.4, 0.4, 0.4, alpha); if (lighthalf)
glColor4f(0.4,0.4,0.4,alpha);
else
glColor4f(0.8,0.8,0.8,alpha);
glBindTexture (GL_TEXTURE_2D, gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (gl->sl, gl->tl); glTexCoord2f (gl->sl, gl->tl);
@ -625,7 +659,10 @@ void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
glTexCoord2f (gl->sl, gl->th); glTexCoord2f (gl->sl, gl->th);
glVertex2f (x, y+pic->height); glVertex2f (x, y+pic->height);
glEnd (); glEnd ();
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
} }
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height) void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height)
@ -647,7 +684,10 @@ void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int h
newtl = gl->tl + (srcy*oldglheight)/pic->height; newtl = gl->tl + (srcy*oldglheight)/pic->height;
newth = newtl + (height*oldglheight)/pic->height; newth = newtl + (height*oldglheight)/pic->height;
glColor3f (0.4, 0.4, 0.4); if (lighthalf)
glColor3f(0.4,0.4,0.4);
else
glColor3f(0.8,0.8,0.8);
glBindTexture (GL_TEXTURE_2D, gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (newsl, newtl); glTexCoord2f (newsl, newtl);
@ -716,7 +756,10 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor3f (0.4, 0.4, 0.4); if (lighthalf)
glColor3f(0.4,0.4,0.4);
else
glColor3f(0.8,0.8,0.8);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (0, 0); glTexCoord2f (0, 0);
glVertex2f (x, y); glVertex2f (x, y);
@ -783,7 +826,10 @@ Draw_ConsoleBackground ( int lines )
alpha = (float)(gl_conalpha->value * lines)/y; alpha = (float)(gl_conalpha->value * lines)/y;
} }
glColor4f (0.5, 0.5, 0.5, alpha); if (lighthalf)
glColor4f(0.4,0.4,0.4,alpha);
else
glColor4f(0.8,0.8,0.8,alpha);
// draw the console texture // draw the console texture
glBindTexture (GL_TEXTURE_2D, gl->texnum); glBindTexture (GL_TEXTURE_2D, gl->texnum);
@ -801,7 +847,10 @@ Draw_ConsoleBackground ( int lines )
// turn off alpha blending // turn off alpha blending
if (alpha < 1.0) if (alpha < 1.0)
{ {
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.4,0.4,0.4);
else
glColor3f(0.8,0.8,0.8);
} }
if (gl_conspin->value) if (gl_conspin->value)
@ -828,7 +877,10 @@ refresh window.
*/ */
void Draw_TileClear (int x, int y, int w, int h) void Draw_TileClear (int x, int y, int w, int h)
{ {
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.4,0.4,0.4);
else
glColor3f(0.8,0.8,0.8);
glBindTexture (GL_TEXTURE_2D, *(int *)draw_backtile->data); glBindTexture (GL_TEXTURE_2D, *(int *)draw_backtile->data);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (x/64.0, y/64.0); glTexCoord2f (x/64.0, y/64.0);
@ -853,9 +905,10 @@ Fills a box of pixels with a single color
void Draw_Fill (int x, int y, int w, int h, int c) void Draw_Fill (int x, int y, int w, int h, int c)
{ {
glDisable (GL_TEXTURE_2D); glDisable (GL_TEXTURE_2D);
glColor3f (host_basepal[c*3]/510.0, if (lighthalf)
host_basepal[c*3+1]/510.0, glColor3f (host_basepal[c*3]/510.0, host_basepal[c*3+1]/510.0, host_basepal[c*3+2]/510.0);
host_basepal[c*3+2]/510.0); else
glColor3f (host_basepal[c*3]/255.0, host_basepal[c*3+1]/255.0, host_basepal[c*3+2]/255.0);
glBegin (GL_QUADS); glBegin (GL_QUADS);
@ -865,7 +918,10 @@ void Draw_Fill (int x, int y, int w, int h, int c)
glVertex2f (x, y+h); glVertex2f (x, y+h);
glEnd (); glEnd ();
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
} }
//============================================================================= //=============================================================================
@ -888,7 +944,10 @@ void Draw_FadeScreen (void)
glVertex2f (0, vid.height); glVertex2f (0, vid.height);
glEnd (); glEnd ();
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
Sbar_Changed(); Sbar_Changed();
@ -948,7 +1007,10 @@ void GL_Set2D (void)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
} }
//==================================================================== //====================================================================

View file

@ -55,6 +55,7 @@
extern byte *draw_chars; // 8*8 graphic characters extern byte *draw_chars; // 8*8 graphic characters
extern qboolean lighthalf;
int netgraphtexture; // netgraph texture int netgraphtexture; // netgraph texture
@ -159,7 +160,10 @@ void R_NetGraph (void)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
x = 8; x = 8;
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
glBegin (GL_QUADS); glBegin (GL_QUADS);
glTexCoord2f (0, 0); glTexCoord2f (0, 0);
glVertex2f (x, y); glVertex2f (x, y);

View file

@ -74,6 +74,7 @@ vec3_t r_pright, r_pup, r_ppn;
fire_t r_fires[MAX_FIRES]; fire_t r_fires[MAX_FIRES];
extern cvar_t *gl_fires; extern cvar_t *gl_fires;
extern qboolean lighthalf;
/* /*
=============== ===============
@ -580,7 +581,10 @@ void R_DrawParticles (void)
// theAlpha = 255*(8-p->ramp)/8; // theAlpha = 255*(8-p->ramp)/8;
else else
theAlpha = 255; theAlpha = 255;
glColor4ub (*at, *(at+1), *(at+2), theAlpha); if (lighthalf)
glColor4ub((byte) ((int) at[0] >> 1), (byte) ((int) at[1] >> 1), (byte) ((int) at[2] >> 1), theAlpha);
else
glColor4ub(at[0], at[1], at[2], theAlpha);
// glColor3ubv (at); // glColor3ubv (at);
// glColor3ubv ((byte *)&d_8to24table[(int)p->color]); // glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
glTexCoord2f (0,0); glTexCoord2f (0,0);
@ -766,7 +770,10 @@ R_DrawFire (fire_t *f)
// we're not - draw it // we're not - draw it
glBegin (GL_TRIANGLE_FAN); glBegin (GL_TRIANGLE_FAN);
glColor3fv (f->color); if (lighthalf)
glColor3f(f->color[0]*0.5,f->color[1]*0.5,f->color[2]*0.5);
else
glColor3fv(f->color);
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
vec[i] = f->origin[i] - vpn[i] * radius; vec[i] = f->origin[i] - vpn[i] * radius;
glVertex3fv (vec); glVertex3fv (vec);

View file

@ -55,6 +55,7 @@
#include "glquake.h" #include "glquake.h"
int r_dlightframecount; int r_dlightframecount;
extern qboolean lighthalf;
/* /*
@ -146,7 +147,10 @@ void R_RenderDlight (dlight_t *light)
glBegin (GL_TRIANGLE_FAN); glBegin (GL_TRIANGLE_FAN);
// glColor3f (0.2,0.1,0.0); // glColor3f (0.2,0.1,0.0);
// glColor3f (0.2,0.1,0.05); // changed dimlight effect // glColor3f (0.2,0.1,0.05); // changed dimlight effect
glColor3fv (light->color); if (lighthalf)
glColor3f(light->color[0]*0.5,light->color[1]*0.5,light->color[2]*0.5);
else
glColor3fv (light->color);
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
v[i] = light->origin[i] - vpn[i]*rad; v[i] = light->origin[i] - vpn[i]*rad;
glVertex3fv (v); glVertex3fv (v);

View file

@ -126,8 +126,14 @@ cvar_t *r_skyname;
extern cvar_t *scr_fov; extern cvar_t *scr_fov;
extern byte gammatable[256]; extern byte gammatable[256];
extern qboolean lighthalf;
static float vid_gamma = 1.0; static float vid_gamma = 1.0;
// LordHavoc: place for gl_rmain setup code
void glrmain_init()
{
};
/* /*
GL_CheckGamma GL_CheckGamma
@ -288,7 +294,10 @@ void R_DrawSpriteModel (entity_t *e)
right = vright; right = vright;
} }
glColor4f (0.5, 0.5, 0.5, 1); if (lighthalf)
glColor4f(0.5,0.5,0.5,1);
else
glColor4f(1,1,1,1);
GL_DisableMultitexture(); GL_DisableMultitexture();
@ -371,15 +380,6 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
verts += posenum * paliashdr->poseverts; verts += posenum * paliashdr->poseverts;
order = (int *)((byte *)paliashdr + paliashdr->commands); order = (int *)((byte *)paliashdr + paliashdr->commands);
if (modelalpha == 0)
modelalpha = 1;
if (shadecolor[0] == 0)
shadecolor[0] = 1;
if (shadecolor[1] == 0)
shadecolor[1] = 1;
if (shadecolor[2] == 0)
shadecolor[2] = 1;
if (modelalpha != 1.0) if (modelalpha != 1.0)
glDepthMask(0); glDepthMask(0);
@ -545,6 +545,12 @@ void R_DrawAliasModel (entity_t *e)
shadecolor[0] = currententity->colormod[0]; shadecolor[0] = currententity->colormod[0];
shadecolor[1] = currententity->colormod[1]; shadecolor[1] = currententity->colormod[1];
shadecolor[2] = currententity->colormod[2]; shadecolor[2] = currententity->colormod[2];
if (lighthalf)
{
shadecolor[0] *= 0.5;
shadecolor[1] *= 0.5;
shadecolor[2] *= 0.5;
}
VectorCopy (currententity->origin, r_entorigin); VectorCopy (currententity->origin, r_entorigin);
VectorSubtract (r_origin, r_entorigin, modelorg); VectorSubtract (r_origin, r_entorigin, modelorg);
@ -748,50 +754,6 @@ void R_DrawViewModel (void)
glDepthRange (gldepthmin, gldepthmax); glDepthRange (gldepthmin, gldepthmax);
} }
/*
============
R_PolyBlend
============
*/
void R_PolyBlend (void)
{
if (!gl_polyblend->value)
return;
if (!v_blend[3])
return;
//Con_Printf("R_PolyBlend(): %4.2f %4.2f %4.2f %4.2f\n",v_blend[0], v_blend[1], v_blend[2], v_blend[3]);
GL_DisableMultitexture();
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glDisable (GL_TEXTURE_2D);
glLoadIdentity ();
glRotatef (-90, 1, 0, 0); // put Z going up
glRotatef (90, 0, 0, 1); // put Z going up
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
// software alpha is about GL alpha squared --KB
// v_blend[3] = sqrt(v_blend[3]);
glColor4fv (v_blend);
glBegin (GL_QUADS);
glVertex3f (10, 100, 100);
glVertex3f (10, -100, 100);
glVertex3f (10, -100, -100);
glVertex3f (10, 100, -100);
glEnd ();
glEnable (GL_TEXTURE_2D);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
int SignbitsForPlane (mplane_t *out) int SignbitsForPlane (mplane_t *out)
{ {
int bits, j; int bits, j;
@ -1128,6 +1090,4 @@ void R_RenderView (void)
// render mirror view // render mirror view
// R_Mirror (); // R_Mirror ();
R_PolyBlend ();
} }

View file

@ -62,8 +62,8 @@ int skytexturenum;
#define GL_RGBA4 0 #define GL_RGBA4 0
#endif #endif
extern vec3_t shadecolor; // Ender (Extend) Colormod extern vec3_t shadecolor; // Ender (Extend) Colormod
int lightmap_bytes; // 1 or 4 int lightmap_bytes; // 1 or 3
int lightmap_textures; int lightmap_textures;
@ -74,7 +74,8 @@ cvar_t *gl_colorlights;
#define BLOCK_WIDTH 128 #define BLOCK_WIDTH 128
#define BLOCK_HEIGHT 128 #define BLOCK_HEIGHT 128
#define MAX_LIGHTMAPS 64 // LordHavoc: since lightmaps are now allocated only as needed, allow a ridiculous number :)
#define MAX_LIGHTMAPS 1024
int active_lightmaps; int active_lightmaps;
typedef struct glRect_s { typedef struct glRect_s {
@ -89,7 +90,8 @@ int allocated[MAX_LIGHTMAPS][BLOCK_WIDTH];
// the lightmap texture data needs to be kept in // the lightmap texture data needs to be kept in
// main memory so texsubimage can update properly // main memory so texsubimage can update properly
byte lightmaps[4*MAX_LIGHTMAPS*BLOCK_WIDTH*BLOCK_HEIGHT]; // LordHavoc: changed to be allocated at runtime (typically lower memory usage)
byte *lightmaps[MAX_LIGHTMAPS];
// For gl_texsort 0 // For gl_texsort 0
msurface_t *skychain = NULL; msurface_t *skychain = NULL;
@ -97,10 +99,38 @@ msurface_t *waterchain = NULL;
void R_RenderDynamicLightmaps (msurface_t *fa); void R_RenderDynamicLightmaps (msurface_t *fa);
extern qboolean lighthalf;
// LordHavoc: place for gl_rsurf setup code
void glrsurf_init()
{
memset(&lightmaps, 0, sizeof(lightmaps));
}
void recursivelightupdate(mnode_t *node)
{
int c;
msurface_t *surf;
if (node->children[0]->contents >= 0)
recursivelightupdate(node->children[0]);
if (node->children[1]->contents >= 0)
recursivelightupdate(node->children[1]);
if (c = node->numsurfaces)
for (surf = cl.worldmodel->surfaces + node->firstsurface; c ; c--, surf++)
surf->cached_dlight = true;
}
// LordHavoc: function to force all lightmaps to be updated
void R_ForceLightUpdate()
{
if (cl.worldmodel && cl.worldmodel->nodes && cl.worldmodel->nodes->contents >= 0)
recursivelightupdate(cl.worldmodel->nodes);
}
/* /*
R_AddDynamicLights R_AddDynamicLights
LordHavoc's redesigned this function completely LordHavoc's lighting
*/ */
void void
R_AddDynamicLights (msurface_t *surf) R_AddDynamicLights (msurface_t *surf)
@ -247,33 +277,67 @@ store:
{ {
stride -= smax * 3; stride -= smax * 3;
bl = blocklights; bl = blocklights;
for (i = 0; i < tmax; i++, dest += stride) if (lighthalf)
for (j=0 ; j<smax ; j++) {
{ for (i = 0; i < tmax; i++, dest += stride)
t = (int) *bl++ >> 8; for (j=0 ; j<smax ; j++)
*dest++ = bound(0, t, 255); {
t = (int) *bl++ >> 8; t = (int) *bl++ >> 8;
*dest++ = bound(0, t, 255); *dest++ = bound(0, t, 255);
t = (int) *bl++ >> 8; t = (int) *bl++ >> 8;
*dest++ = bound(0, t, 255); *dest++ = bound(0, t, 255);
} t = (int) *bl++ >> 8;
*dest++ = bound(0, t, 255);
}
}
else
{
for (i = 0; i < tmax; i++, dest += stride)
for (j=0 ; j<smax ; j++)
{
t = (int) *bl++ >> 7;
*dest++ = bound(0, t, 255);
t = (int) *bl++ >> 7;
*dest++ = bound(0, t, 255);
t = (int) *bl++ >> 7;
*dest++ = bound(0, t, 255);
}
}
} }
else else
{ {
stride -= smax; stride -= smax;
bl = blocklights; bl = blocklights;
for (i = 0; i < tmax; i++, dest += stride) if (lighthalf)
for (j=0 ; j<smax ; j++) {
{ for (i = 0; i < tmax; i++, dest += stride)
t = (int) *bl++ >> 8; for (j=0 ; j<smax ; j++)
t2 = bound(0, t, 255); {
t = (int) *bl++ >> 8; t = (int) *bl++ >> 8;
t2 += bound(0, t, 255); t2 = bound(0, t, 255);
t = (int) *bl++ >> 8; t = (int) *bl++ >> 8;
t2 += bound(0, t, 255); t2 += bound(0, t, 255);
t2 *= (1.0/3.0); t = (int) *bl++ >> 8;
*dest++ = t2; t2 += bound(0, t, 255);
} t2 *= (1.0/3.0);
*dest++ = t2;
}
}
else
{
for (i = 0; i < tmax; i++, dest += stride)
for (j=0 ; j<smax ; j++)
{
t = (int) *bl++ >> 7;
t2 = bound(0, t, 255);
t = (int) *bl++ >> 7;
t2 += bound(0, t, 255);
t = (int) *bl++ >> 7;
t2 += bound(0, t, 255);
t2 *= (1.0/3.0);
*dest++ = t2;
}
}
} }
} }
@ -599,8 +663,7 @@ dynamic:
theRect->w = (fa->light_s-theRect->l)+smax; theRect->w = (fa->light_s-theRect->l)+smax;
if ((theRect->h + theRect->t) < (fa->light_t + tmax)) if ((theRect->h + theRect->t) < (fa->light_t + tmax))
theRect->h = (fa->light_t-theRect->t)+tmax; theRect->h = (fa->light_t-theRect->t)+tmax;
base = lightmaps + fa->lightmaptexturenum*lightmap_bytes*BLOCK_WIDTH*BLOCK_HEIGHT; base = lightmaps[fa->lightmaptexturenum] + fa->light_t * BLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes;
base += fa->light_t * BLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes;
R_BuildLightMap (fa, base, BLOCK_WIDTH*lightmap_bytes); R_BuildLightMap (fa, base, BLOCK_WIDTH*lightmap_bytes);
} }
} }
@ -657,8 +720,7 @@ dynamic:
theRect->w = (fa->light_s-theRect->l)+smax; theRect->w = (fa->light_s-theRect->l)+smax;
if ((theRect->h + theRect->t) < (fa->light_t + tmax)) if ((theRect->h + theRect->t) < (fa->light_t + tmax))
theRect->h = (fa->light_t-theRect->t)+tmax; theRect->h = (fa->light_t-theRect->t)+tmax;
base = lightmaps + fa->lightmaptexturenum*lightmap_bytes*BLOCK_WIDTH*BLOCK_HEIGHT; base = lightmaps[fa->lightmaptexturenum] + fa->light_t * BLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes;
base += fa->light_t * BLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes;
R_BuildLightMap (fa, base, BLOCK_WIDTH*lightmap_bytes); R_BuildLightMap (fa, base, BLOCK_WIDTH*lightmap_bytes);
} }
} }
@ -698,13 +760,12 @@ void R_DrawWaterSurfaces (void)
glLoadMatrixf (r_world_matrix); glLoadMatrixf (r_world_matrix);
if (r_wateralpha->value < 1.0) if (lighthalf)
{ glColor4f(0.5,0.5,0.5, r_wateralpha->value);
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
else else
glColor3f (0.5, 0.5, 0.5); glColor4f(1,1,1, r_wateralpha->value);
if (r_wateralpha->value < 1.0)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (!gl_texsort->value) if (!gl_texsort->value)
{ {
@ -745,8 +806,7 @@ void R_DrawWaterSurfaces (void)
} }
if (r_wateralpha->value < 1.0) glColor3f(1,1,1);
glColor3f (0.5, 0.5, 0.5);
} }
@ -1147,6 +1207,10 @@ int AllocBlock (int w, int h, int *x, int *y)
if (best + h > BLOCK_HEIGHT) if (best + h > BLOCK_HEIGHT)
continue; continue;
// LordHavoc: allocate lightmaps only as needed
if (!lightmaps[texnum])
lightmaps[texnum] = calloc(BLOCK_WIDTH * BLOCK_HEIGHT, 3);
for (i=0 ; i<w ; i++) for (i=0 ; i<w ; i++)
allocated[texnum][*x + i] = best + h; allocated[texnum][*x + i] = best + h;
@ -1294,8 +1358,7 @@ void GL_CreateSurfaceLightmap (msurface_t *surf)
tmax = (surf->extents[1]>>4)+1; tmax = (surf->extents[1]>>4)+1;
surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t); surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
base = lightmaps + surf->lightmaptexturenum*lightmap_bytes*BLOCK_WIDTH*BLOCK_HEIGHT; base = lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
base += (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
R_BuildLightMap (surf, base, BLOCK_WIDTH*lightmap_bytes); R_BuildLightMap (surf, base, BLOCK_WIDTH*lightmap_bytes);
} }

View file

@ -1114,6 +1114,9 @@ void SCR_TileClear (void)
} }
float oldsbar = 0; float oldsbar = 0;
extern void R_ForceLightUpdate();
qboolean lighthalf;
extern cvar_t *gl_lightmode, *brightness, *contrast;
/* /*
================== ==================
@ -1129,6 +1132,7 @@ needs almost the entire 256k of stack space!
void SCR_UpdateScreen (void) void SCR_UpdateScreen (void)
{ {
double time1 = 0, time2; double time1 = 0, time2;
float f;
if (block_drawing) if (block_drawing)
return; return;
@ -1182,6 +1186,14 @@ void SCR_UpdateScreen (void)
// //
// do 3D refresh drawing, and then update the screen // do 3D refresh drawing, and then update the screen
// //
// LordHavoc: set lighthalf based on gl_lightmode cvar
if (lighthalf != (gl_lightmode->value != 0))
{
lighthalf = gl_lightmode->value != 0;
R_ForceLightUpdate();
}
SCR_SetUpToDrawConsole (); SCR_SetUpToDrawConsole ();
V_RenderView (); V_RenderView ();
@ -1233,19 +1245,59 @@ void SCR_UpdateScreen (void)
M_Draw (); M_Draw ();
} }
// LordHavoc's lighting fix // LordHavoc: adjustable brightness and contrast,
glDisable (GL_TEXTURE_2D); // also makes polyblend apply to whole screen
glColor3f (1.0, 1.0, 1.0); glDisable(GL_TEXTURE_2D);
glBlendFunc (GL_DST_COLOR, GL_ONE); glEnable(GL_BLEND);
glBegin (GL_QUADS); brightness->value = bound(1, brightness->value, 5);
glVertex2f (0,0); if (lighthalf) // LordHavoc: render was done at half brightness
glVertex2f (vid.width, 0); f = brightness->value * 2;
glVertex2f (vid.width, vid.height); else
glVertex2f (0, vid.height); f = brightness->value;
glEnd (); if (f > 1)
{
glBlendFunc (GL_DST_COLOR, GL_ONE);
glBegin (GL_QUADS);
while (f > 1)
{
if (f >= 2)
glColor3f (1, 1, 1);
else
glColor3f (f-1, f-1, f-1);
glVertex2f (0,0);
glVertex2f (vid.width, 0);
glVertex2f (vid.width, vid.height);
glVertex2f (0, vid.height);
f *= 0.5;
}
glEnd ();
}
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D); contrast->value = bound(0.2, contrast->value, 1.0);
if ((gl_polyblend->value && v_blend[3]) || contrast->value < 1)
{
glBegin (GL_QUADS);
if (contrast->value < 1)
{
glColor4f (1, 1, 1, 1-contrast->value);
glVertex2f (0,0);
glVertex2f (vid.width, 0);
glVertex2f (vid.width, vid.height);
glVertex2f (0, vid.height);
}
if (gl_polyblend->value && v_blend[3])
{
glColor4fv (v_blend);
glVertex2f (0,0);
glVertex2f (vid.width, 0);
glVertex2f (vid.width, vid.height);
glVertex2f (0, vid.height);
}
glEnd ();
}
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
V_UpdatePalette (); V_UpdatePalette ();

View file

@ -48,6 +48,7 @@ extern double realtime;
extern model_t *loadmodel; extern model_t *loadmodel;
extern int skytexturenum; extern int skytexturenum;
extern qboolean lighthalf;
int solidskytexture; int solidskytexture;
int alphaskytexture; int alphaskytexture;
@ -655,7 +656,10 @@ R_DrawSkyBox (void)
// glDisable (GL_BLEND); // glDisable (GL_BLEND);
// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDepthRange (gldepthmax, gldepthmax); glDepthRange (gldepthmax, gldepthmax);
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
{ {
@ -735,7 +739,10 @@ R_DrawSkyDome (void)
// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthRange (gldepthmax, gldepthmax); glDepthRange (gldepthmax, gldepthmax);
glColor3f (0.5, 0.5, 0.5); if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
// base sky // base sky
glBindTexture (GL_TEXTURE_2D, solidskytexture); glBindTexture (GL_TEXTURE_2D, solidskytexture);