ref_soft: clamp alpha values

This commit is contained in:
mittorn 2019-04-04 10:27:18 +07:00
parent 500ff629bf
commit 338b404055
3 changed files with 26 additions and 2 deletions

View File

@ -996,6 +996,8 @@ Normal surface cached, texture mapped surface
*/
void D_AlphaSurf (surf_t *s)
{
int alpha;
d_zistepu = s->d_zistepu;
d_zistepv = s->d_zistepv;
d_ziorigin = s->d_ziorigin;
@ -1052,13 +1054,16 @@ void D_AlphaSurf (surf_t *s)
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip * pface->texinfo->mipadjust);
}
#endif
alpha = RI.currententity->curstate.renderamt * 7 / 255;
if( alpha <= 0 && RI.currententity->curstate.renderamt > 0 )
alpha = 1;
if (s->flags & SURF_DRAWTURB )
{
cacheblock = R_GetTexture(pface->texinfo->texture->gl_texturenum)->pixels[0];
cachewidth = 64;
D_CalcGradients (pface);
TurbulentZ8( s->spans, RI.currententity->curstate.renderamt * 7 / 255 );
TurbulentZ8( s->spans, alpha);
}
else
{
@ -1070,12 +1075,14 @@ void D_AlphaSurf (surf_t *s)
D_CalcGradients (pface);
if( RI.currententity->curstate.rendermode == kRenderTransAlpha )
D_AlphaSpans16(s->spans);
else if( RI.currententity->curstate.rendermode == kRenderTransAdd )
D_AddSpans16(s->spans);
else
D_BlendSpans16(s->spans, RI.currententity->curstate.renderamt * 7 / 255 );
D_BlendSpans16(s->spans, alpha );
}
VectorCopy (world_transformed_modelorg,

View File

@ -231,6 +231,13 @@ void R_BuildBlendMaps()
r = r1 * (7 - a) / 7 + (r2 << 2 | BIT(2)) * a / 7;
g = g1 * (7 - a) / 7 + (g2 << 3 | MASK(2)) * a / 7;
b = b1 * (7 - a) / 7 + (b2 << 3 | MASK(2)) * a / 7;
if( r > MASK(5) )
r = MASK(5);
if( g > MASK(6) )
g = MASK(6);
if( b > MASK(5) )
b = MASK(5);
ASSERT( b < 32 );
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));

View File

@ -297,6 +297,11 @@ void TurbulentZ8 (espan_t *pspan, int alpha1)
float sdivz16stepu, tdivz16stepu, zi16stepu;
alpha = alpha1;
if( alpha > 7 )
alpha = 7;
if( alpha == 0 )
return;
r_turb_turb = sintable + ((int)(gpGlobals->time*SPEED)&(CYCLE-1));
r_turb_sstep = 0; // keep compiler happy
@ -960,6 +965,11 @@ void D_BlendSpans16 (espan_t *pspan, int alpha)
int izi, izistep;
short *pz;
if( alpha > 7 )
alpha = 7;
if( alpha == 0 )
return;
sstep = 0; // keep compiler happy
tstep = 0; // ditto