scale and readjust 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 09:52:09 +01:00
1 parent f332e21fa7
commit a209fffbe2
4 files changed
+32 -7

No files matched your search

+1
View File
@@ -338,6 +338,7 @@ enum hwdshaderinfo
HWD_SHADERINFO_LIGHT_Z,
HWD_SHADERINFO_LIGHT_CONTRAST,
HWD_SHADERINFO_LIGHT_BACKLIGHT,
HWD_SHADERINFO_FLATSIZE,
};
typedef enum hwdshaderinfo hwdshaderinfo_t;
+4
View File
@@ -727,6 +727,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
PolyFlags |= PF_ColorMapped;
}
GL_SetShaderInfo(HWD_SHADERINFO_FLATSIZE, (INT32)fflatsize);
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false);
if (subsector && subsector->hashorizon && cv_glhorizonlines.value)
@@ -994,6 +996,8 @@ static void HWR_RenderFOFHorizonPlane(subsector_t *subsector, extrasubsector_t *
PolyFlags |= PF_ColorMapped;
}
GL_SetShaderInfo(HWD_SHADERINFO_FLATSIZE, (INT32)fflatsize);
// Horizon lines
FOutVector horizonpts[6];
float dist, vx, vy;
+15 -7
View File
@@ -230,20 +230,26 @@
// Still needs to distort things underneath/around the water...
//
// readjusted to match software much more closely
#define GLSL_WATER_CONST \
"const float freq = 0.07;\n" \
"const float amp = 0.07;\n" \
"const float speed = 3.8;\n" \
"const float pi = 3.14159;\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 sdistort = sin(a) * amp;\n" \
"float cdistort = cos(a) * amp;\n" \
"vec4 texel = texture2D(tex, vec2(gl_TexCoord[0].s - sdistort, gl_TexCoord[0].t - cdistort));\n"
"float falloff = 1.0 / (1.0 + water_z * falltresh);\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" \
GLSL_FLOOR_FUDGES \
"const float freq = 0.025;\n" \
"const float amp = 0.025;\n" \
"const float speed = 2.0;\n" \
"const float pi = 3.14159;\n" \
GLSL_WATER_CONST \
"#ifdef SRB2_PALETTE_RENDERING\n" \
"uniform sampler2D tex;\n" \
"uniform sampler3D palette_lookup_tex;\n" \
@@ -251,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 \
@@ -265,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" \
+12
View File
@@ -759,6 +759,8 @@ typedef enum
// misc.
gluniform_leveltime,
gluniform_flatsize,
gluniform_scr_resolution,
// postprocess stuff
@@ -800,6 +802,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;
@@ -1099,6 +1103,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;
}
@@ -2340,6 +2347,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);
@@ -2478,6 +2488,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");