From b601da004e7d6068d5174c92d060c1e5250c6559 Mon Sep 17 00:00:00 2001 From: Alexander Shishkin Date: Sun, 13 Oct 2024 03:30:57 +0300 Subject: [PATCH] shaders: Make blur shaders make sense Signed-off-by: Alexander Shishkin --- shaders/hblur.frag | 24 ++++++++++++------------ shaders/hblur.vert | 7 +++---- shaders/vblur.frag | 24 ++++++++++++------------ shaders/vblur.vert | 7 +++---- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/shaders/hblur.frag b/shaders/hblur.frag index 34d70a0..176b9aa 100644 --- a/shaders/hblur.frag +++ b/shaders/hblur.frag @@ -10,15 +10,15 @@ void main() { FragColor = vec4(0.0); - FragColor += texture(model_tex, blur_coords[0]) * 0.0093; - FragColor += texture(model_tex, blur_coords[1]) * 0.028002; - FragColor += texture(model_tex, blur_coords[2]) * 0.065984; - FragColor += texture(model_tex, blur_coords[3]) * 0.121703; - FragColor += texture(model_tex, blur_coords[4]) * 0.175713; - FragColor += texture(model_tex, blur_coords[5]) * 0.198596; - FragColor += texture(model_tex, blur_coords[6]) * 0.175713; - FragColor += texture(model_tex, blur_coords[7]) * 0.121703; - FragColor += texture(model_tex, blur_coords[8]) * 0.065984; - FragColor += texture(model_tex, blur_coords[9]) * 0.028002; - FragColor += texture(model_tex, blur_coords[10]) * 0.0093; -} \ No newline at end of file + FragColor += texture(model_tex, pass_tex + blur_coords[0]) * 0.0093; + FragColor += texture(model_tex, pass_tex + blur_coords[1]) * 0.028002; + FragColor += texture(model_tex, pass_tex + blur_coords[2]) * 0.065984; + FragColor += texture(model_tex, pass_tex + blur_coords[3]) * 0.121703; + FragColor += texture(model_tex, pass_tex + blur_coords[4]) * 0.175713; + FragColor += texture(model_tex, pass_tex + blur_coords[5]) * 0.198596; + FragColor += texture(model_tex, pass_tex + blur_coords[6]) * 0.175713; + FragColor += texture(model_tex, pass_tex + blur_coords[7]) * 0.121703; + FragColor += texture(model_tex, pass_tex + blur_coords[8]) * 0.065984; + FragColor += texture(model_tex, pass_tex + blur_coords[9]) * 0.028002; + FragColor += texture(model_tex, pass_tex + blur_coords[10]) * 0.0093; +} diff --git a/shaders/hblur.vert b/shaders/hblur.vert index ccaff1e..8e90864 100644 --- a/shaders/hblur.vert +++ b/shaders/hblur.vert @@ -11,10 +11,9 @@ out vec2 blur_coords[11]; void main() { - gl_Position = /*trans * */vec4(position, 1.0); + gl_Position = trans * vec4(position, 1.0); pass_tex = tex; - vec2 center_coords = position.xy * 0.5 + 0.5; float pixsz = 1.0 / width; for (int i = -5; i <= 5; i++) - blur_coords[i + 5] = center_coords + vec2(pixsz * float(i), 0.0); -} \ No newline at end of file + blur_coords[i + 5] = vec2(pixsz * float(i), 0.0); +} diff --git a/shaders/vblur.frag b/shaders/vblur.frag index 34d70a0..176b9aa 100644 --- a/shaders/vblur.frag +++ b/shaders/vblur.frag @@ -10,15 +10,15 @@ void main() { FragColor = vec4(0.0); - FragColor += texture(model_tex, blur_coords[0]) * 0.0093; - FragColor += texture(model_tex, blur_coords[1]) * 0.028002; - FragColor += texture(model_tex, blur_coords[2]) * 0.065984; - FragColor += texture(model_tex, blur_coords[3]) * 0.121703; - FragColor += texture(model_tex, blur_coords[4]) * 0.175713; - FragColor += texture(model_tex, blur_coords[5]) * 0.198596; - FragColor += texture(model_tex, blur_coords[6]) * 0.175713; - FragColor += texture(model_tex, blur_coords[7]) * 0.121703; - FragColor += texture(model_tex, blur_coords[8]) * 0.065984; - FragColor += texture(model_tex, blur_coords[9]) * 0.028002; - FragColor += texture(model_tex, blur_coords[10]) * 0.0093; -} \ No newline at end of file + FragColor += texture(model_tex, pass_tex + blur_coords[0]) * 0.0093; + FragColor += texture(model_tex, pass_tex + blur_coords[1]) * 0.028002; + FragColor += texture(model_tex, pass_tex + blur_coords[2]) * 0.065984; + FragColor += texture(model_tex, pass_tex + blur_coords[3]) * 0.121703; + FragColor += texture(model_tex, pass_tex + blur_coords[4]) * 0.175713; + FragColor += texture(model_tex, pass_tex + blur_coords[5]) * 0.198596; + FragColor += texture(model_tex, pass_tex + blur_coords[6]) * 0.175713; + FragColor += texture(model_tex, pass_tex + blur_coords[7]) * 0.121703; + FragColor += texture(model_tex, pass_tex + blur_coords[8]) * 0.065984; + FragColor += texture(model_tex, pass_tex + blur_coords[9]) * 0.028002; + FragColor += texture(model_tex, pass_tex + blur_coords[10]) * 0.0093; +} diff --git a/shaders/vblur.vert b/shaders/vblur.vert index 37bcb46..c80e0ae 100644 --- a/shaders/vblur.vert +++ b/shaders/vblur.vert @@ -11,10 +11,9 @@ out vec2 blur_coords[11]; void main() { - gl_Position = /*trans * */vec4(position, 1.0); + gl_Position = vec4(position, 1.0); pass_tex = tex; - vec2 center_coords = position.xy * 0.5 + 0.5; float pixsz = 1.0 / height; for (int i = -5; i <= 5; i++) - blur_coords[i + 5] = center_coords + vec2(0.0, pixsz * float(i)); -} \ No newline at end of file + blur_coords[i + 5] = vec2(0.0, pixsz * float(i)); +}