From b9fb85edaa6ad8530dad6535a1e1e01935f42ae0 Mon Sep 17 00:00:00 2001 From: Kurt Wilson Date: Mon, 23 Jan 2023 20:06:35 -0500 Subject: [PATCH] :beetle: Allow glitch to distort the left side of the window --- resources/shaders/glitch.frag | 6 +++--- resources/shaders/tv-glitch.frag | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/shaders/glitch.frag b/resources/shaders/glitch.frag index 0bf24216..9f5e5375 100644 --- a/resources/shaders/glitch.frag +++ b/resources/shaders/glitch.frag @@ -29,11 +29,11 @@ void main() { float yPos = uScale * uSize.y * (iTexCoord.y + uSeed * 10.0); // Create large noise waves and add some smaller noise waves. - float noise = clamp(simplex2D(vec2(time, yPos * 0.002)) - 0.5, 0.0, 1.0); + float noise = clamp(simplex2D(vec2(time, yPos * 0.002)) - 0.5, -1.0, 1.0); noise += (simplex2D(vec2(time * 10.0, yPos * 0.05)) - 0.5) * 0.15; // Apply the noise as x displacement for every line. - float xPos = clamp(iTexCoord.x - displace * noise * noise, 0.0, 1.0); + float xPos = clamp(iTexCoord.x - displace * noise * noise * sign(noise), -1.0, 1.0); vec4 oColor = getInputColor(vec2(xPos, iTexCoord.y)); // Mix in some random interference lines. @@ -62,4 +62,4 @@ void main() { oColor.a *= alpha; setOutputColor(oColor); -} \ No newline at end of file +} diff --git a/resources/shaders/tv-glitch.frag b/resources/shaders/tv-glitch.frag index 8d861f38..23b65d0b 100644 --- a/resources/shaders/tv-glitch.frag +++ b/resources/shaders/tv-glitch.frag @@ -49,11 +49,11 @@ void main() { float yPos = uScale * uSize.y * (coords.y + uSeed * 10.0); // Create large noise waves and add some smaller noise waves. - float noise = clamp(simplex2D(vec2(time, yPos * 0.002)) - 0.5, 0.0, 1.0); + float noise = clamp(simplex2D(vec2(time, yPos * 0.002)) - 0.5, -1.0, 1.0); noise += (simplex2D(vec2(time * 10.0, yPos * 0.05)) - 0.5) * 0.15; // Apply the noise as x displacement for every line. - float xPos = clamp(coords.x - displace * noise * noise, 0.0, 1.0); + float xPos = clamp(coords.x - displace * noise * noise * sign(noise), -1.0, 1.0); vec4 oColor = getInputColor(vec2(xPos, coords.y)); // Mix in some random interference lines.