From 85eff81c7f08a97bca216dd901ef63059ac5602e Mon Sep 17 00:00:00 2001 From: Andrei Alexeyev Date: Wed, 28 Aug 2024 12:54:37 +0200 Subject: [PATCH] resources/shader/fxaa: don't rely on magic _SIZE uniform --- resources/00-taisei.pkgdir/shader/fxaa.vert.glsl | 2 +- resources/00-taisei.pkgdir/shader/interface/fxaa.glslh | 2 +- src/stagedraw.c | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/00-taisei.pkgdir/shader/fxaa.vert.glsl b/resources/00-taisei.pkgdir/shader/fxaa.vert.glsl index d6b02b29..1d810ca5 100644 --- a/resources/00-taisei.pkgdir/shader/fxaa.vert.glsl +++ b/resources/00-taisei.pkgdir/shader/fxaa.vert.glsl @@ -6,7 +6,7 @@ void main(void) { gl_Position = r_projectionMatrix * r_modelViewMatrix * vec4(position, 1.0); - v_rcpFrame = 1.0 / tex_SIZE; + v_rcpFrame = 1.0 / tex_size; fxaaCoords( texCoordRawIn, v_rcpFrame, diff --git a/resources/00-taisei.pkgdir/shader/interface/fxaa.glslh b/resources/00-taisei.pkgdir/shader/interface/fxaa.glslh index 903fca11..69bdb041 100644 --- a/resources/00-taisei.pkgdir/shader/interface/fxaa.glslh +++ b/resources/00-taisei.pkgdir/shader/interface/fxaa.glslh @@ -14,7 +14,7 @@ OUT(0) vec4 fragColor; #endif UNIFORM(0) sampler2D tex; -UNIFORM(1) vec2 tex_SIZE; +UNIFORM(1) vec2 tex_size; UNIFORM(2) sampler2D depth; VARYING(0) vec2 v_coordNW; diff --git a/src/stagedraw.c b/src/stagedraw.c index 4cf3d57b..3e951cc7 100644 --- a/src/stagedraw.c +++ b/src/stagedraw.c @@ -574,6 +574,10 @@ static bool fxaa_rule(Framebuffer *fb) { r_depth_func(DEPTH_ALWAYS); r_blend(BLEND_NONE); r_shader_ptr(stagedraw.shaders.fxaa); + Texture *tex = r_framebuffer_get_attachment(fb, FRAMEBUFFER_ATTACH_COLOR0); + uint w, h; + r_texture_get_size(tex, 0, &w, &h); + r_uniform_vec2("tex_size", w, h); r_uniform_sampler("depth", r_framebuffer_get_attachment(fb, FRAMEBUFFER_ATTACH_DEPTH)); draw_framebuffer_tex(fb, VIEWPORT_W, VIEWPORT_H); r_state_pop();