Skip to content

Instantly share code, notes, and snippets.

@SuperSonicHub1
Last active December 9, 2024 03:20
Show Gist options
  • Save SuperSonicHub1/e3cabde37d6da6f85f38d7a2970dd89f to your computer and use it in GitHub Desktop.
Save SuperSonicHub1/e3cabde37d6da6f85f38d7a2970dd89f to your computer and use it in GitHub Desktop.
Neato datamoshing GLSL shader for Shadertoy
// iChannel0: webcam
// iChannel1: Brittney
// make sure both sources are on repeat
// shoutouts to einrail
// Unlicensed: https://unlicense.org/
// Seconds
#define P1 15.
#define P2 2.
#define P3 20.
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 N1 = fragCoord/iResolution.xy;
vec2 N2 = vec2(N1.x, N1.y + 1./P3 * iTime);
vec3 lsamp = texture(iChannel0, N2).xyz;
vec3 rsamp = texture(iChannel1, N1).xyz;
float t1 = 0.3 * abs(sin(1./P1 * iTime)) + 0.3;
vec3 samp = lsamp * ((1. - t1) * rsamp) + 0.2;
vec3 modified = vec3(
float((floatBitsToInt(samp.x) & iFrame) % 255) / 255.0,
float((floatBitsToInt(samp.y) | iFrame) % 255) / 255.0,
float((floatBitsToInt(samp.z) ^ iFrame) % 255) / 255.0
);
float t2 = abs(sin(1./P2 * iTime));
vec3 avg = modified * t2 + samp * (1. - t2);
fragColor = vec4(avg,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment