Browse Source

ref_soft: clamp alpha values

pull/2/head
mittorn 6 years ago
parent
commit
338b404055
  1. 11
      r_edge.c
  2. 7
      r_glblit.c
  3. 10
      r_scan.c

11
r_edge.c

@ -996,6 +996,8 @@ Normal surface cached, texture mapped surface @@ -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) @@ -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) @@ -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,

7
r_glblit.c

@ -231,6 +231,13 @@ void R_BuildBlendMaps() @@ -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)));

10
r_scan.c

@ -297,6 +297,11 @@ void TurbulentZ8 (espan_t *pspan, int alpha1) @@ -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) @@ -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

Loading…
Cancel
Save