diff --git a/engine/client/renderer.c b/engine/client/renderer.c index f70c51a02..fe2f1b701 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -279,7 +279,6 @@ void GLRenderer_Init(void) //renderer Cvar_Register (&r_novis, GLRENDEREROPTIONS); - Cvar_Register (&r_wateralpha, GLRENDEREROPTIONS); Cvar_Register (&r_mirroralpha, GLRENDEREROPTIONS); Cvar_Register (&r_norefresh, GLRENDEREROPTIONS); @@ -564,6 +563,7 @@ void Renderer_Init(void) Cvar_Register (&r_fastsky, GRAPHICALNICETIES); Cvar_Register (&r_fastskycolour, GRAPHICALNICETIES); + Cvar_Register (&r_wateralpha, GRAPHICALNICETIES); Cvar_Register (&r_drawflat, GRAPHICALNICETIES); Cvar_Register (&r_menutint, GRAPHICALNICETIES); diff --git a/engine/sw/r_draw.c b/engine/sw/r_draw.c index 33b6b19f3..f5d1c42ee 100644 --- a/engine/sw/r_draw.c +++ b/engine/sw/r_draw.c @@ -632,6 +632,7 @@ R_RenderFace */ void R_RenderFace (msurface_t *fa, int clipflags) { + extern float r_wateralphaval; int i, lindex; unsigned mask; mplane_t *pplane; @@ -650,6 +651,16 @@ void R_RenderFace (msurface_t *fa, int clipflags) return; } + if (r_wateralphaval != 1.0 && fa->flags & SURF_DRAWTURB) + { + if (fa->nextalphasurface) + return; + + fa->nextalphasurface = r_alpha_surfaces; + r_alpha_surfaces = fa; + return; + } + if ( fa->texinfo->flags & SURF_SKY) { if (R_EmitSkyBox ()) @@ -1351,7 +1362,7 @@ void R_8DrawSpanletAlphaBlend( void ) //8 bit rendering only { unsigned btemp; - D_SetTransLevel(r_q2polydesc.alpha*255.0, BM_BLEND); + D_SetTransLevel(r_q2polydesc.alpha/255.0, BM_BLEND); do { @@ -1383,7 +1394,7 @@ void R_8DrawSpanletTurbulentAlphaBlend( void ) extern int *r_turb_turb; unsigned btemp; - D_SetTransLevel(r_q2polydesc.alpha*255.0, BM_BLEND); + D_SetTransLevel(r_q2polydesc.alpha/255.0, BM_BLEND); do { @@ -2099,6 +2110,8 @@ void R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured ) { if (alpha == 1 && !isturbulent) r_q2polydesc.drawspanlet = R_32DrawSpanletAlphaTest; + else if (alpha <= 0) + return; else { r_q2polydesc.alpha = alpha*255; @@ -2110,7 +2123,9 @@ void R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured ) } else if (r_pixbytes == 2) { - if (alpha < 0.5) + if (alpha < 0.2) + return; + else if (alpha < 0.5) r_q2polydesc.drawspanlet = R_16DrawSpanlet33Stipple; else if (alpha < 0.9) r_q2polydesc.drawspanlet = R_16DrawSpanlet66Stipple; @@ -2121,6 +2136,8 @@ void R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured ) { if (alpha >= TRANS_UPPER_CAP) r_q2polydesc.drawspanlet = R_8DrawSpanletAlphaTest; + else if (alpha <= TRANS_LOWER_CAP) + return; else if (isturbulent) { r_q2polydesc.alpha = alpha*255; @@ -2227,7 +2244,7 @@ void R_BuildPolygonFromSurface(msurface_t *fa) } // PGM 09/16/98 - if ( fa->texinfo->flags & (SURF_WARP|SURF_FLOWING) ) + if ( fa->texinfo->flags & (SURF_WARP|SURF_FLOWING) || (fa->flags & SURF_DRAWTURB) ) { r_q2polydesc.pixels = (qbyte *)fa->texinfo->texture + fa->texinfo->texture->offsets[0]; r_q2polydesc.pixel_width = fa->texinfo->texture->width; @@ -2278,7 +2295,12 @@ void SWR_DrawAlphaSurfaces( void ) { R_BuildPolygonFromSurface( s ); - if (s->texinfo->flags & SURF_TRANS66) + if (s->flags & SURF_DRAWTURB) + { + extern float r_wateralphaval; + R_ClipAndDrawPoly( r_wateralphaval, true, true ); + } + else if (s->texinfo->flags & SURF_TRANS66) { R_ClipAndDrawPoly( 0.66f, (s->texinfo->flags & (SURF_WARP|SURF_FLOWING)), true ); } diff --git a/engine/sw/r_main.c b/engine/sw/r_main.c index 92f000a88..c962bed45 100644 --- a/engine/sw/r_main.c +++ b/engine/sw/r_main.c @@ -89,6 +89,8 @@ float screenAspect; float verticalFieldOfView; float xOrigin, yOrigin; +float r_wateralphaval; + mplane_t screenedge[4]; //colour bits (for 16 bit rendering) diff --git a/engine/sw/r_misc.c b/engine/sw/r_misc.c index 8469cc5ef..52dd2fb95 100644 --- a/engine/sw/r_misc.c +++ b/engine/sw/r_misc.c @@ -457,12 +457,17 @@ void SWR_SetupFrame (void) extern int r_dosirds; extern int scr_chatmode; + extern float r_wateralphaval; int edgecount; vrect_t vrect; float w, h; + // don't allow cheats in multiplayer + r_wateralphaval = r_wateralpha.value; + if (!cls.allow_watervis) + r_wateralphaval = 1; if (r_numsurfs.value) {