Reputation: 7429
I am trying to learn more about how to use shader within webgl. Currently I'll try to apply a "mirror" effect to an immage. If I use a plain canvas, I can do this by simply call: scale(1,-1);
The result is something like this (copied from Wikipedia)
Is there a nice way to apply this effect using a shader?
Upvotes: 0
Views: 1021
Reputation: 169075
Try something like this (or variations of the X coordinate transformation :) )
void main(void)
{
vec2 uv = gl_FragCoord.xy / iResolution.xy;
gl_FragColor = texture2D(iChannel0, vec2(abs(0.5 - uv.x), uv.y));
}
Here's an image of the above in Shadertoy. Just assign a texture or video into iChannel0.
Upvotes: 2