diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index 555c24707..fb6763036 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -290,6 +290,7 @@ void GLR_LessenStains(void) stmap *stain; int stride; int ammount; + int limit; static float time; @@ -301,7 +302,8 @@ void GLR_LessenStains(void) return; time-=r_stainfadetime.value; - ammount = 255 - r_stainfadeammount.value; + ammount = r_stainfadeammount.value; + limit = 255 - ammount; surf = cl.worldmodel->surfaces; for (i=0 ; inumsurfaces ; i++, surf++) @@ -326,7 +328,7 @@ void GLR_LessenStains(void) { for (s=0 ; sstained=true; @@ -1011,9 +1013,9 @@ store: if (isstained) // merge in stain { - r = (128+r*(*stain++)) >> 8; - g = (128+g*(*stain++)) >> 8; - b = (128+b*(*stain++)) >> 8; + r = (127+r*(*stain++)) >> 8; + g = (127+g*(*stain++)) >> 8; + b = (127+b*(*stain++)) >> 8; } cr = 0; @@ -1169,9 +1171,9 @@ store: if (isstained) // merge in stain { - r = (128+r*(*stain++)) >> 8; - g = (128+g*(*stain++)) >> 8; - b = (128+b*(*stain++)) >> 8; + r = (127+r*(*stain++)) >> 8; + g = (127+g*(*stain++)) >> 8; + b = (127+b*(*stain++)) >> 8; } cr = 0; @@ -1364,9 +1366,9 @@ store: if (isstained) // merge in stain { - r = (128+r*(*stain++)) >> 8; - g = (128+g*(*stain++)) >> 8; - b = (128+b*(*stain++)) >> 8; + r = (127+r*(*stain++)) >> 8; + g = (127+g*(*stain++)) >> 8; + b = (127+b*(*stain++)) >> 8; } cr = 0; @@ -1522,9 +1524,9 @@ store: if (isstained) // merge in stain { - r = (128+r*(*stain++)) >> 8; - g = (128+g*(*stain++)) >> 8; - b = (128+b*(*stain++)) >> 8; + r = (127+r*(*stain++)) >> 8; + g = (127+g*(*stain++)) >> 8; + b = (127+b*(*stain++)) >> 8; } cr = 0; @@ -3357,6 +3359,8 @@ int GLAllocBlock (int w, int h, int *x, int *y) if (!lightmap[texnum]) { lightmap[texnum] = Z_Malloc(sizeof(*lightmap[texnum])); + // reset stainmap since it now starts at 255 + memset(lightmap[texnum]->stainmaps, 255, sizeof(lightmap[texnum]->stainmaps)); } diff --git a/engine/sw/r_surf.c b/engine/sw/r_surf.c index 808be6804..bb15f3325 100644 --- a/engine/sw/r_surf.c +++ b/engine/sw/r_surf.c @@ -149,7 +149,7 @@ void SWR_StainSurf (msurface_t *surf, float *parms) dist = td + (sd>>1); if (dist < minlight) { - amm = stainbase[(s)] + (dist - rad)*parms[4]; + amm = stainbase[(s)] - (dist - rad)*parms[4]; stainbase[(s)] = bound(0, amm, 255); surf->stained = true; @@ -255,7 +255,7 @@ void SWR_LessenStains(void) int s, t; stmap *stain; int stride; - int ammount; + int ammount, limit; static float time; @@ -270,7 +270,8 @@ void SWR_LessenStains(void) return; time-=r_stainfadetime.value; - ammount = 255 - r_stainfadeammount.value; + ammount = r_stainfadeammount.value; + limit = 255 - ammount; surf = cl.worldmodel->surfaces; for (i=0 ; inumsurfaces ; i++, surf++) @@ -295,7 +296,7 @@ void SWR_LessenStains(void) { for (s=0 ; sstained=true; @@ -819,7 +820,7 @@ void SWR_BuildLightMap (void) { for (y = 0; y < smax; y++, i++, stain++) { - t = (255*256*256-128*256-(int)blocklights[i]*(*stain)) >> (16 - VID_CBITS); + t = (255*256*256-127*256-(int)blocklights[i]*(*stain)) >> (16 - VID_CBITS); if (t < (1 << 6)) t = (1 << 6); @@ -907,9 +908,9 @@ void SWR_BuildLightMapRGB (void) { for (y = 0; y < smax; y++, i+=3, stain++) { - r = (255*256*256-128*256-(int)blocklights[i]*(*stain)) >> 16 - VID_CBITS; - g = (255*256*256-128*256-(int)blocklights[i+1]*(*stain)) >> 16 - VID_CBITS; - b = (255*256*256-128*256-(int)blocklights[i+2]*(*stain)) >> 16 - VID_CBITS; + r = (255*256*256-127*256-(int)blocklights[i]*(*stain)) >> 16 - VID_CBITS; + g = (255*256*256-127*256-(int)blocklights[i+1]*(*stain)) >> 16 - VID_CBITS; + b = (255*256*256-127*256-(int)blocklights[i+2]*(*stain)) >> 16 - VID_CBITS; #define MINL (1<<6) #define MAXL ((255*256) >> (8 - VID_CBITS))