added partial r_stains

changed default of r_stains to 0.75


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1723 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2005-12-17 21:51:42 +00:00
parent 2cd3740b2f
commit 96de3b78c3
4 changed files with 102 additions and 106 deletions

View file

@ -101,69 +101,70 @@ void SWR_StainSurf (msurface_t *surf, float *parms)
int i;
int smax, tmax;
float amm;
int lim;
mtexinfo_t *tex;
stmap *stainbase;
lim = 255 - (bound(0, r_stains.value, 1)*255);
smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1;
tex = surf->texinfo;
stainbase = stainmaps + surf->lightmaptexturenum*LMBLOCK_WIDTH*LMBLOCK_HEIGHT;
stainbase += (surf->light_t * LMBLOCK_WIDTH + surf->light_s);
stainbase = stainmaps + surf->lightmaptexturenum*LMBLOCK_WIDTH*LMBLOCK_HEIGHT;
stainbase += (surf->light_t * LMBLOCK_WIDTH + surf->light_s);
rad = *parms;
dist = DotProduct ((parms+1), surf->plane->normal) - surf->plane->dist;
rad -= fabs(dist);
minlight = 0;
if (rad < minlight) //not hit
return;
minlight = rad - minlight;
for (i=0 ; i<3 ; i++)
{
impact[i] = (parms+1)[i] - surf->plane->normal[i]*dist;
}
rad = *parms;
dist = DotProduct ((parms+1), surf->plane->normal) - surf->plane->dist;
rad -= fabs(dist);
minlight = 0;
if (rad < minlight) //not hit
return;
minlight = rad - minlight;
local[0] = DotProduct (impact, tex->vecs[0]) + tex->vecs[0][3];
local[1] = DotProduct (impact, tex->vecs[1]) + tex->vecs[1][3];
for (i=0 ; i<3 ; i++)
local[0] -= surf->texturemins[0];
local[1] -= surf->texturemins[1];
for (t = 0 ; t<tmax ; t++)
{
td = local[1] - t*16;
if (td < 0)
td = -td;
for (s=0 ; s<smax ; s++)
{
impact[i] = (parms+1)[i] - surf->plane->normal[i]*dist;
}
local[0] = DotProduct (impact, tex->vecs[0]) + tex->vecs[0][3];
local[1] = DotProduct (impact, tex->vecs[1]) + tex->vecs[1][3];
local[0] -= surf->texturemins[0];
local[1] -= surf->texturemins[1];
for (t = 0 ; t<tmax ; t++)
{
td = local[1] - t*16;
if (td < 0)
td = -td;
for (s=0 ; s<smax ; s++)
sd = local[0] - s*16;
if (sd < 0)
sd = -sd;
if (sd > td)
dist = sd + (td>>1);
else
dist = td + (sd>>1);
if (dist < minlight)
{
sd = local[0] - s*16;
if (sd < 0)
sd = -sd;
if (sd > td)
dist = sd + (td>>1);
else
dist = td + (sd>>1);
if (dist < minlight)
{
amm = stainbase[(s)] - (dist - rad)*parms[4];
stainbase[(s)] = bound(0, amm, 255);
amm = stainbase[(s)] - (dist - rad)*parms[4];
stainbase[(s)] = bound(lim, amm, 255);
surf->stained = true;
}
surf->stained = true;
}
stainbase += LMBLOCK_WIDTH;
}
stainbase += LMBLOCK_WIDTH;
}
if (surf->stained)
{
for (i = 0; i < 4; i++)
if (surf->cachespots[i])
surf->cachespots[i]->dlight = -1;
}
if (surf->stained)
{
for (i = 0; i < 4; i++)
if (surf->cachespots[i])
surf->cachespots[i]->dlight = -1;
}
}
//combination of R_AddDynamicLights and R_MarkLights
@ -216,7 +217,7 @@ void SWR_AddStain(vec3_t org, float red, float green, float blue, float radius)
if (red != green && red != blue) //sw only does luminance of stain maps
return; //a mix would look wrong.
if (!r_stains.value || !cl.worldmodel)
if (r_stains.value <= 0 || !cl.worldmodel)
return;
parms[0] = radius;
parms[1] = org[0];
@ -259,7 +260,7 @@ void SWR_LessenStains(void)
static float time;
if (!r_stains.value || cl.paused)
if (r_stains.value <= 0 || cl.paused)
{
time = 0;
return;