Created
August 23, 2021 19:26
-
-
Save ewpratten/793504860e9b6a39e7f3c25094dcc1d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Viewport dimensions | |
const vec2 viewport = vec2(1080.0, 720.0); | |
// Pixel scaling | |
const vec2 pixelScale = vec2(2.0, 2.0); | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
// Calculate the distance to merge pixels | |
float dx = pixelScale.x * (1.0 / viewport.x); | |
float dy = pixelScale.y * (1.0 / viewport.y); | |
// Get the base UV coordinate of the pixel | |
vec2 baseUV = fragCoord/iResolution.xy; | |
// Use a wave function to translate the pixel UV | |
float X = baseUV.x*0.5+iTime; | |
float Y = baseUV.y*0.25+iTime; | |
baseUV.y += cos(X+Y)*0.0025*cos(Y); | |
baseUV.x += sin(X-Y)*0.012*sin(Y); | |
// Calculate a UV for this new blocky pixel | |
vec2 pixelatedUV = vec2(dx * floor(baseUV.x / dx), dy * floor(baseUV.y / dy)); | |
// Rebuild the texture with the new UVs | |
vec3 tc = texture(iChannel0, pixelatedUV).rgb; | |
// Apply a color filter | |
tc = tc + vec3(0, 0.05, 0.15); | |
// Build the final pixel | |
fragColor = vec4(tc, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment