Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪲 Allow glitch to distort the left side of the window #289

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
10 changes: 8 additions & 2 deletions resources/shaders/tv-glitch.frag
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ 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);
// non-branching version of
// if xPos > 1: xPos -=1
// elif xPos < -1: xPos +=1
// else: xPos = 0
xPos = mod(xPos + 1.0, 2.0) - 1.0;

vec4 oColor = getInputColor(vec2(xPos, coords.y));

// Mix in some random interference lines.
Expand Down
Loading