From 519131afc487efbfaf95f5fb38166a08cf484a72 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 29 Jan 2016 12:16:51 -0700 Subject: [PATCH] fix water alpha --- quakespasm/Quake/glquake.h | 1 + quakespasm/Quake/r_brush.c | 2 +- quakespasm/Quake/r_world.c | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/quakespasm/Quake/glquake.h b/quakespasm/Quake/glquake.h index f654521b..a456bd31 100644 --- a/quakespasm/Quake/glquake.h +++ b/quakespasm/Quake/glquake.h @@ -341,6 +341,7 @@ void R_DrawBrushModel (entity_t *e); void R_DrawSpriteModel (entity_t *e); void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain); +void R_DrawTextureChains_GLSL_Water (qmodel_t *model, entity_t *ent, texchain_t chain); void R_RenderDlights (void); void GL_BuildLightmaps (void); diff --git a/quakespasm/Quake/r_brush.c b/quakespasm/Quake/r_brush.c index bb9e5e78..4dc60e2d 100644 --- a/quakespasm/Quake/r_brush.c +++ b/quakespasm/Quake/r_brush.c @@ -586,7 +586,7 @@ void R_DrawBrushModel (entity_t *e) } R_DrawTextureChains (clmodel, e, chain_model); - R_DrawTextureChains_Water (clmodel, e, chain_model); + R_DrawTextureChains_GLSL_Water (clmodel, e, chain_model); glPopMatrix (); } diff --git a/quakespasm/Quake/r_world.c b/quakespasm/Quake/r_world.c index 4234272a..a9814405 100644 --- a/quakespasm/Quake/r_world.c +++ b/quakespasm/Quake/r_world.c @@ -37,6 +37,7 @@ static GLuint r_brush_program; // uniforms used in frag shader static GLuint clTimeLoc; static GLuint texLoc; +static GLuint waterAlphaLoc; /* @@ -67,6 +68,7 @@ void GLBrush_CreateShaders (void) "\n" "uniform sampler2D Tex;\n" "uniform float ClTime;\n" + "uniform float WaterAlpha;\n" "\n" "// From RMQEngine:\n" "#define M_PI 3.14159\n" @@ -78,14 +80,14 @@ void GLBrush_CreateShaders (void) "\n" "void main()\n" "{\n" - " vec2 texc = vec2(WARPCALC(gl_TexCoord[0].x * 64.0, gl_TexCoord[0].y * 64.0), WARPCALC(gl_TexCoord[0].y * 64.0, gl_TexCoord[0].x * 64.0));\n" + " vec2 texc = vec2(WARPCALC(gl_TexCoord[0].x * 128.0, gl_TexCoord[0].y * 128.0), WARPCALC(gl_TexCoord[0].y * 128.0, gl_TexCoord[0].x * 128.0));\n" " vec4 result = texture2D(Tex, texc);\n" " result = clamp(result, 0.0, 1.0);\n" " // apply GL_EXP2 fog (from the orange book)\n" " float fog = exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord);\n" " fog = clamp(fog, 0.0, 1.0);\n" " result = mix(gl_Fog.color, result, fog);\n" - " result.a = 0.4;//gl_Color.a;\n" + " result.a = WaterAlpha;\n" " gl_FragColor = result;\n" "}\n"; @@ -99,6 +101,7 @@ void GLBrush_CreateShaders (void) // get uniform locations clTimeLoc = GL_GetUniformLocation (&r_brush_program, "ClTime"); texLoc = GL_GetUniformLocation (&r_brush_program, "Tex"); + waterAlphaLoc = GL_GetUniformLocation (&r_brush_program, "WaterAlpha"); } } @@ -1071,6 +1074,7 @@ void R_DrawTextureChains_GLSL_Water (qmodel_t *model, entity_t *ent, texchain_t { entalpha = GL_WaterAlphaForEntitySurface (ent, s); R_BeginTransparentDrawing (entalpha); + GL_Uniform1fFunc (waterAlphaLoc, entalpha); GL_Bind (t->gltexture); bound = true; }