So I wrote this GLSL fragment shader for shadertoy:
const float INTENSITY = 0.5;
const float SPEED = 0.5;
const float SIZE = 0.2;
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = gl_FragCoord.xy / iResolution.xy;
vec4 color = texture(iChannel0, uv);
vec2 ghostOffset = vec2(cos(uv.y * SPEED * sin(iTime)), sin(uv.x * SPEED));
color += INTENSITY * texture(iChannel0, uv + ghostOffset * SIZE);
fragColor = color;
}
https://www.shadertoy.com/view/dsjXD3
However, the resulting image seems to wrap over at the side. I know why this happens (UV is getting above {1., 1.}
or below {0., 0.}
), but I don't know how to fix it. Do you have any suggestions?
Thanks
Tuxifan