From 76f912e753aace11481a5fd360bc2da0e60e4ee2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Nov 2026 21:55:11 +0100 Subject: [PATCH] fix uv clamps in the RR screen shaders forgor this makes sure the shaders dont sample outside the screen region as the screen textures may not be exactly screen sized --- src/hardware/hw_shaders.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 5f30f56e7..6dcde1fd0 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -376,25 +376,31 @@ /* #define GLSL_POSTPROCESS_FRAGMENT_WATER \ "uniform sampler2D tex;\n" \ + "uniform vec2 scr_resolution;\n" \ + "uniform vec2 scr_tex_size;\n" \ "uniform float leveltime;\n" \ "void main(void) {\n" \ "vec2 uv = gl_TexCoord[0].st;\n" \ + "vec2 maxuv = scr_resolution / scr_tex_size;\n" \ "float y = 1.0 - uv.y;\n" \ "uv.x += sin(leveltime * 2.0 + y * 20.0) * 0.01;\n" \ - "uv = clamp(uv, vec2(0.0), vec2(0.9999));\n" \ + "uv = clamp(uv, vec2(0.0), maxuv - vec2(0.0001));\n" \ "gl_FragColor = texture2D(tex, uv);\n" \ "}\0" #define GLSL_POSTPROCESS_FRAGMENT_HEAT \ "uniform sampler2D tex;\n" \ + "uniform vec2 scr_resolution;\n" \ + "uniform vec2 scr_tex_size;\n" \ "uniform float leveltime;\n" \ "void main(void) {\n" \ "vec2 uv = gl_TexCoord[0].st;\n" \ + "vec2 maxuv = scr_resolution / scr_tex_size;\n" \ "float y = 1.0 - uv.y;\n" \ "float time = leveltime * 35.0;\n" \ "uv.x += max(sin((time / 35.0) * 1.2 - y * 5.0) - 0.995, 0.0);\n" \ "uv.x -= max(sin(((time + 24.0) / 35.0) * 0.2 - y * 1.5) - 0.990, 0.0);\n" \ - "uv = clamp(uv, vec2(0.0), vec2(0.9999));\n" \ + "uv = clamp(uv, vec2(0.0), maxuv - vec2(0.0001));\n" \ "gl_FragColor = texture2D(tex, uv);\n" \ "}\0" */