I'm trying to make a perspective bending GLSL shader similar to this.
Original:
Perspective Bending:
void mainImage( out vec4 fragColor, in vec2 fragCoord ){
vec2 uv = fragCoord.xy/iResolution.xy;
if (uv.x + uv.y < 1.0) uv = 1.0 - vec2(uv.y, uv.x);
fragColor = texture(iChannel0, uv);
}
The code above does not achieve exactly what I want; your help is appreciated!

The reason why the line is not at a 45° angle and doesn't end where it should is that by dividing
fragCoord.xybyiResolution.xy, you scale the x and y axes by different amounts. In your situation, since the image is wider than it is tall,uvwill be stretched horizontally. To avoid that, I suggest you to do the scaling after the mirror transformation :Note that I replaced the
1.0s byiResolution.ysince in this coordinate system, that is the height of your image.