From 5f122ab240bd120bbb5a247f64aed5622e3a37cc Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Wed, 12 Jun 2024 15:52:04 +0200 Subject: [PATCH] Small optimization to the blur shader --- assets/shaders/engine/editorBlurFast.frag | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/assets/shaders/engine/editorBlurFast.frag b/assets/shaders/engine/editorBlurFast.frag index 75ef96af..43fa6ed2 100644 --- a/assets/shaders/engine/editorBlurFast.frag +++ b/assets/shaders/engine/editorBlurFast.frag @@ -13,17 +13,12 @@ float uBrightness = 0.6; vec4 getColor(vec2 pos) { vec2 ps = (pos); - if (ps.x < 0.0) ps.x = 0.0; - //else if (ps.x > 1.0 - (1.0 / iResolution.x)) ps.x = 1.0 - (1.0 / iResolution.x); - else if (ps.x > 1.0) return vec4(0.0); - if (ps.y < 0.0) ps.y = 0.0; - //else if (ps.y > 1.0 - (1.0 / iResolution.y)) return ps.y = 1.0 - (1.0 / iResolution.y); - else if (ps.y > 1.0) return vec4(0.0); + ps = clamp(ps, vec2(0.0), vec2(1.0));//1.0 - (1.0 / iResolution.xy)); return flixel_texture2D(bitmap, (ps)); } -vec2 fixvec2(float x, float y) { // makes an uv the same across sizes +/*vec2 fixvec2(float x, float y) { // makes an uv the same across sizes vec2 val = vec2(x, y); val.xy *= vec2(1280.0, 720.0); val.xy /= iResolution.xy; @@ -34,7 +29,7 @@ vec2 fixvec2(vec2 uv) { // makes an uv the same across sizes val.xy *= vec2(1280.0, 720.0); val.xy /= iResolution.xy; return val; -} +}*/ vec2 random(vec2 p) { p = vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))); @@ -53,7 +48,7 @@ void main() { vec4 a = getColor(camPos+(random(camPos)*blur - blur / 2.0)) * uBrightness; a += getColor(camPos+(random(camPos+0.1)*blur - blur / 2.0)) * uBrightness; - a += getColor(camPos+(random(camPos+0.2)*blur - blur / 2.0)) * uBrightness; + //a += getColor(camPos+(random(camPos+0.2)*blur - blur / 2.0)) * uBrightness; //a += getColor(camPos+(random(camPos+0.3)*blur - blur / 2.0)) * uBrightness; - gl_FragColor = a / 3.0; + gl_FragColor = a / 2.0; } \ No newline at end of file