#define TAU 6.2831853072 uniform vec2 origin = vec2(0.0, 0.0); uniform float direction = 0.0; uniform float amplitude = 10.0; uniform float length = 10.0; uniform float evolution = 0.0; vec2 distanceDirection(vec2 pos) { float angle = direction * TAU; vec2 normal = vec2(cos(angle), sin(angle)); vec2 relative = pos - origin; return vec2(dot(normal, relative), angle + TAU / 4); } vec2 generateShift(vec2 pos) { vec2 dd = distanceDirection(pos); float shift = amplitude * sin(dd.x / length - evolution * TAU); return vec2(shift * cos(dd.y), shift * sin(dd.y)); } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 shift = generateShift(fragCoord.xy / iRenderScale) * iRenderScale; fragColor = texture2D( iChannel0, (fragCoord.xy + shift) / iResolution.xy); }