scale the ripple shader in gl

unbelievably annoying since we still gotta support old gl & glsl versions (glsl 1.30 can just fetch texturesizes directly....)
basically this ensures the ripple does not become super strong on flats that are super large (iirc anything marsh related lol)
its scaled to always match the size of a 64x64 flat, since thats what i tuned the shader to
this matches software much more closely
This commit is contained in:
alufolie91 committed 2026-11-20 10:35:22 +01:00
1 parent adcc5eb90a
commit 89f226dde5
4 files changed
+22 -7

No files matched your search

+1
View File
@@ -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;
-2
View File
@@ -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;
+6 -5
View File
@@ -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" \
+15
View File
@@ -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");