From: lordhavoc Date: Thu, 14 Sep 2000 01:00:13 +0000 (+0000) Subject: Implemented r_ambient (mainly for sake of Nehahra's insanely dark maps). X-Git-Tag: RELEASE_0_2_0_RC1~991 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=c19997f205e980d0968874e442aa3c39c9e93017;hp=e9e47ab1cc26ca266eb185efdfa2ba919690b0b9 Implemented r_ambient (mainly for sake of Nehahra's insanely dark maps). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@29 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 79a5a973..6179c7e2 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1324,7 +1324,10 @@ void R_SetupFrame (void) { // don't allow cheats in multiplayer if (cl.maxclients > 1) + { Cvar_Set ("r_fullbright", "0"); + Cvar_Set ("r_ambient", "0"); + } R_AnimateLight (); diff --git a/gl_rsurf.c b/gl_rsurf.c index 9d85c898..17ebd298 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -46,6 +46,7 @@ cvar_t gl_lightmapalign = {"gl_lightmapalign", "4"}; cvar_t gl_lightmaprgba = {"gl_lightmaprgba", "1"}; cvar_t gl_nosubimagefragments = {"gl_nosubimagefragments", "0"}; cvar_t gl_nosubimage = {"gl_nosubimage", "0"}; +cvar_t r_ambient = {"r_ambient", "0"}; qboolean lightmaprgba, nosubimagefragments, nosubimage; int lightmapbytes; @@ -62,11 +63,12 @@ void glrsurf_init() Cvar_RegisterVariable(&gl_lightmaprgba); Cvar_RegisterVariable(&gl_nosubimagefragments); Cvar_RegisterVariable(&gl_nosubimage); + Cvar_RegisterVariable(&r_ambient); // check if it's the glquake minigl driver if (strncasecmp(gl_vendor,"3Dfx",4)==0) if (!gl_arrays) { - Cvar_SetValue("gl_nosubimagefragments", 1); +// Cvar_SetValue("gl_nosubimagefragments", 1); // Cvar_SetValue("gl_nosubimage", 1); Cvar_SetValue("gl_lightmode", 0); } @@ -188,6 +190,7 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride) surf->cached_dlight = (surf->dlightframe == r_framecount); surf->cached_lighthalf = lighthalf; + surf->cached_ambient = r_ambient.value; smax = (surf->extents[0]>>4)+1; tmax = (surf->extents[1]>>4)+1; @@ -209,11 +212,12 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride) { // clear to no light bl = blocklights; + j = r_ambient.value * 512.0f; // would be 256.0f logically, but using 512.0f to match winquake style for (i=0 ; idlightframe == r_framecount || s->cached_dlight || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed + if (s->dlightframe == r_framecount || s->cached_dlight || r_ambient.value != s->cached_ambient || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed, or r_ambient changed R_UpdateLightmap(s, s->lightmaptexturenum); else for (maps = 0 ; maps < MAXLIGHTMAPS && s->styles[maps] != 255 ; maps++) @@ -563,7 +567,7 @@ void DrawTextureChains (void) else if (s->dlightframe == r_dlightframecount && r_dynamic.value) light = true; else - r = g = b = lighthalf ? 64 : 128; + r = g = b = (lighthalf ? 64 : 128) + (int) (r_ambient.value * 2.0f); if (r_waterripple.value) { if (lighthalf) @@ -581,7 +585,7 @@ void DrawTextureChains (void) nv[0] = v[0]; nv[1] = v[1]; nv[2] = v[2] + r_waterripple.value * turbsin[(int)((v[3]*0.125f+realtime) * TURBSCALE) & 255] * turbsin[(int)((v[4]*0.125f+realtime) * TURBSCALE) & 255] * (1.0f / 64.0f); - shadecolor[0] = shadecolor[1] = shadecolor[2] = 128; + shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f); R_DynamicLightPoint(shadecolor, nv, s->dlightbits); transpolyvert(nv[0], nv[1], nv[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), (int) shadecolor[0] >> 1,(int) shadecolor[1] >> 1,(int) shadecolor[2] >> 1,alpha); } @@ -624,7 +628,7 @@ void DrawTextureChains (void) nv[0] = v[0]; nv[1] = v[1]; nv[2] = v[2] + r_waterripple.value * turbsin[(int)((v[3]*0.125f+realtime) * TURBSCALE) & 255] * turbsin[(int)((v[4]*0.125f+realtime) * TURBSCALE) & 255] * (1.0f / 64.0f); - shadecolor[0] = shadecolor[1] = shadecolor[2] = 128; + shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f); R_DynamicLightPoint(shadecolor, nv, s->dlightbits); transpolyvert(nv[0], nv[1], nv[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), shadecolor[0],shadecolor[1],shadecolor[2],alpha); } @@ -667,7 +671,7 @@ void DrawTextureChains (void) transpolybegin(s->texinfo->texture->gl_texturenum, s->texinfo->texture->gl_glowtexturenum, 0, TPOLYTYPE_ALPHA); for (i = 0,v = p->verts[0];i < p->numverts;i++, v += VERTEXSIZE) { - shadecolor[0] = shadecolor[1] = shadecolor[2] = 128; + shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f); R_DynamicLightPoint(shadecolor, v, s->dlightbits); transpolyvert(v[0], v[1], v[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), (int) shadecolor[0] >> 1,(int) shadecolor[1] >> 1,(int) shadecolor[2] >> 1,alpha); } @@ -704,7 +708,7 @@ void DrawTextureChains (void) transpolybegin(s->texinfo->texture->gl_texturenum, s->texinfo->texture->gl_glowtexturenum, 0, TPOLYTYPE_ALPHA); for (i = 0,v = p->verts[0];i < p->numverts;i++, v += VERTEXSIZE) { - shadecolor[0] = shadecolor[1] = shadecolor[2] = 128; + shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f); R_DynamicLightPoint(shadecolor, v, s->dlightbits); transpolyvert(v[0], v[1], v[2], (v[3] + os) * (1.0f/64.0f), (v[4] + ot) * (1.0f/64.0f), shadecolor[0],shadecolor[1],shadecolor[2],alpha); } @@ -870,15 +874,15 @@ e->angles[0] = -e->angles[0]; // stupid quake bug { if (lighthalf) { - r = 64.0f * currententity->colormod[0]; - g = 64.0f * currententity->colormod[1]; - b = 64.0f * currententity->colormod[2]; + r = 64.0f * currententity->colormod[0] + (int) r_ambient.value; + g = 64.0f * currententity->colormod[1] + (int) r_ambient.value; + b = 64.0f * currententity->colormod[2] + (int) r_ambient.value; } else { - r = 128.0f * currententity->colormod[0]; - g = 128.0f * currententity->colormod[1]; - b = 128.0f * currententity->colormod[2]; + r = 128.0f * currententity->colormod[0] + (int) (r_ambient.value * 2.0f); + g = 128.0f * currententity->colormod[1] + (int) (r_ambient.value * 2.0f); + b = 128.0f * currententity->colormod[2] + (int) (r_ambient.value * 2.0f); } } for (p=s->polys ; p ; p=p->next) @@ -892,7 +896,7 @@ e->angles[0] = -e->angles[0]; // stupid quake bug nv[2] += r_waterripple.value * turbsin[(int)((v[3]*0.125f+realtime) * TURBSCALE) & 255] * turbsin[(int)((v[4]*0.125f+realtime) * TURBSCALE) & 255] * (1.0f / 64.0f); if (light) { - shadecolor[0] = shadecolor[1] = shadecolor[2] = 128; + shadecolor[0] = shadecolor[1] = shadecolor[2] = 128 + (int) (r_ambient.value * 2.0f); R_DynamicLightPoint(shadecolor, nv, s->dlightbits); if (lighthalf) { @@ -934,7 +938,7 @@ e->angles[0] = -e->angles[0]; // stupid quake bug size3 = smax*tmax*3; // *3 for colored lighting for (i = 0;i < s->polys->numverts;i++, v += VERTEXSIZE) { - shadecolor[0] = shadecolor[1] = shadecolor[2] = 0; + shadecolor[0] = shadecolor[1] = shadecolor[2] = r_ambient.value * 2.0f; lm = (byte *)((long) s->samples + ((int) v[8] * smax + (int) v[7]) * 3); // LordHavoc: *3 for colored lighting for (maps = 0;maps < MAXLIGHTMAPS && s->styles[maps] != 255;maps++) { @@ -963,7 +967,7 @@ e->angles[0] = -e->angles[0]; // stupid quake bug // check for lightmap modification if (r_dynamic.value) { - if (s->dlightframe == r_framecount || s->cached_dlight || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed + if (s->dlightframe == r_framecount || s->cached_dlight || r_ambient.value != s->cached_ambient || lighthalf != s->cached_lighthalf) // dynamic this frame or previously, or lighthalf changed R_UpdateLightmap(s, s->lightmaptexturenum); else for (maps = 0 ; maps < MAXLIGHTMAPS && s->styles[maps] != 255 ; maps++) diff --git a/model_brush.h b/model_brush.h index 625da010..8deb6abb 100644 --- a/model_brush.h +++ b/model_brush.h @@ -137,6 +137,7 @@ typedef struct msurface_s int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap qboolean cached_dlight; // true if dynamic light in cache qboolean cached_lighthalf; // LordHavoc: to cause lightmap to be rerendered when lighthalf changes + float cached_ambient; // LordHavoc: rerender lightmaps when r_ambient changes byte *samples; // [numstyles*surfsize] } msurface_t; diff --git a/r_light.c b/r_light.c index af8003c2..defa8f0d 100644 --- a/r_light.c +++ b/r_light.c @@ -203,6 +203,8 @@ LIGHT SAMPLING mplane_t *lightplane; vec3_t lightspot; +extern cvar_t r_ambient; + int RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end) { float front, back, frac; @@ -303,7 +305,7 @@ void R_LightPoint (vec3_t color, vec3_t p) end[1] = p[1]; end[2] = p[2] - 2048; - color[0] = color[1] = color[2] = 0; + color[0] = color[1] = color[2] = r_ambient.value * 2.0f; RecursiveLightPoint (color, cl.worldmodel->nodes, p, end); } diff --git a/r_part.c b/r_part.c index 914e54ea..c75968cc 100644 --- a/r_part.c +++ b/r_part.c @@ -44,7 +44,7 @@ int r_numparticles; vec3_t r_pright, r_pup, r_ppn; cvar_t r_particles = {"r_particles", "1"}; -cvar_t r_dynamicparticles = {"r_dynamicparticles", "1"}; +cvar_t r_dynamicparticles = {"r_dynamicparticles", "0", TRUE}; void fractalnoise(char *noise, int size); void fractalnoise_zeroedge(char *noise, int size);