Skip to content

Commit

Permalink
🪲 allow glitch to distort the left side of the window
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurtoid committed Jan 24, 2023
1 parent 7ab0781 commit 67885c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions resources/shaders/glitch.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,4 +62,4 @@ void main() {
oColor.a *= alpha;

setOutputColor(oColor);
}
}
4 changes: 2 additions & 2 deletions resources/shaders/tv-glitch.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 67885c7

Please sign in to comment.