diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 40e8af249..67a90f468 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -339,6 +339,7 @@ enum hwdshaderinfo HWD_SHADERINFO_LIGHT_Z, HWD_SHADERINFO_LIGHT_CONTRAST, HWD_SHADERINFO_LIGHT_BACKLIGHT, + HWD_SHADERINFO_FLATSIZE, }; typedef enum hwdshaderinfo hwdshaderinfo_t; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 6e950d0b5..dc4b70d13 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -733,9 +733,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool if (PolyFlags & PF_Fog) shader = SHADER_FOG; else if (cv_ripplewater.value && (PolyFlags & PF_Ripple)) - { shader = SHADER_WATER; - } else shader = SHADER_FLOOR; diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 0e65dd0b5..202565f43 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -235,17 +235,16 @@ #define GLSL_WATER_CONST \ "const float freq = 0.07;\n" \ "const float amp = 0.07;\n" \ - "const float amp_t = 0.025;\n" \ - "const float speed = 4.0;\n" \ + "const float speed = 3.8;\n" \ "const float pi = 3.14159;\n" \ - "const float falltresh = 0.007;\n" \ + "const float falltresh = 0.007;\n" #define GLSL_WATER_TEXEL \ "float water_z = (gl_FragCoord.z / gl_FragCoord.w) / 2.0;\n" \ "float a = -pi * (water_z * freq) + (leveltime * speed);\n" \ "float falloff = 1.0 / (1.0 + water_z * falltresh);\n" \ - "float distort = sin(a) * amp * falloff;\n" \ - "vec4 texel = texture2D(tex, vec2(gl_TexCoord[0].s - distort, gl_TexCoord[0].t));\n" \ + "float distort = sin(a) * amp * falloff * (64.0 / flat_size);\n" \ + "vec4 texel = texture2D(tex, vec2(gl_TexCoord[0].s - distort, gl_TexCoord[0].t));\n" #define GLSL_WATER_FRAGMENT_SHADER \ "#version 120\n" \ @@ -258,6 +257,7 @@ "uniform vec4 poly_color;\n" \ "uniform float lighting;\n" \ "uniform float leveltime;\n" \ + "uniform float flat_size;\n" \ GLSL_DOOM_COLORMAP \ "void main(void) {\n" \ GLSL_WATER_TEXEL \ @@ -272,6 +272,7 @@ "uniform float fade_start;\n" \ "uniform float fade_end;\n" \ "uniform float leveltime;\n" \ + "uniform float flat_size;\n" \ GLSL_DOOM_COLORMAP \ GLSL_DOOM_LIGHT_EQUATION \ "void main(void) {\n" \ diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8d6626791..0318eec2c 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -771,6 +771,8 @@ typedef enum // misc. gluniform_leveltime, + gluniform_flatsize, + gluniform_scr_resolution, // postprocess stuff @@ -812,6 +814,8 @@ static float shader_light_z = 0.0f; static INT32 shader_light_contrast = 0; static INT32 shader_light_backlight = 0; +static INT32 shader_flatsize = 64; + static float shader_vhs_rewind = 1.0f; static float shader_vhs_time = 0.0f; @@ -1111,6 +1115,9 @@ void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value) case HWD_SHADERINFO_LIGHT_BACKLIGHT: shader_light_backlight = value; break; + case HWD_SHADERINFO_FLATSIZE: + shader_flatsize = value; + break; default: break; } @@ -2244,6 +2251,7 @@ void GL_SetTexture(GLMipmap_t *pTexInfo) if (!pTexInfo) { GL_SetNoTexture(); + GL_SetShaderInfo(HWD_SHADERINFO_FLATSIZE, 0); return; } @@ -2277,6 +2285,8 @@ void GL_SetTexture(GLMipmap_t *pTexInfo) else // initialization of the linked list TexCacheTail = TexCacheHead = newTex; } + + GL_SetShaderInfo(HWD_SHADERINFO_FLATSIZE, (INT32)pTexInfo->width); } static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade) @@ -2352,6 +2362,9 @@ static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRG UNIFORM_2(shader->uniforms[gluniform_scr_resolution], (GLfloat)screen_width, (GLfloat)screen_height, pglUniform2f); + // super annoying, if only we could ditch glsl 1.20 and older..... + UNIFORM_1(shader->uniforms[gluniform_flatsize], (GLfloat)shader_flatsize, pglUniform1f); + // grrrrr stupid 2.0 support.. used similar to yfix, xfix UNIFORM_2(shader->uniforms[gluniform_scr_tex_size], (GLfloat)screen_texsizew, (GLfloat)screen_texsizeh, pglUniform2f); @@ -2490,6 +2503,8 @@ static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i) // misc. shader->uniforms[gluniform_leveltime] = GETUNI("leveltime"); + shader->uniforms[gluniform_flatsize] = GETUNI("flat_size"); + // postprocessor stuff (water/heat effect) shader->uniforms[gluniform_scr_tex_size] = GETUNI("scr_tex_size");