fixes to stainmaps (project options got screwed up so I didn't catch the glitches)

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1658 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2005-12-02 00:49:20 +00:00
parent bc44aaf54b
commit 1b2dfa9701
2 changed files with 27 additions and 22 deletions

View file

@ -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 ; i<cl.worldmodel->numsurfaces ; i++, surf++)
@ -326,7 +328,7 @@ void GLR_LessenStains(void)
{
for (s=0 ; s<smax ; s++)
{
if (*stain < ammount) //eventually decay to 255
if (*stain < limit) //eventually decay to 255
{
*stain += ammount;
surf->stained=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));
}

View file

@ -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 ; i<cl.worldmodel->numsurfaces ; i++, surf++)
@ -295,7 +296,7 @@ void SWR_LessenStains(void)
{
for (s=0 ; s<smax ; s++)
{
if (*stain < ammount)
if (*stain < limit)
{
*stain += ammount;
surf->stained=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))