plɹoM ollǝH

ǝldɯᴉs puɐ llɐɯs ʇᴉ dǝǝʞ

歪曲収差 glsl

void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
    vec2 uv = fragCoord.xy / iResolution.xy;
    vec2 v = uv - vec2(0.5);    
    float k1 = 1.5;
    float k2 = 0.5;
    float r1 = length(v);
    float r2 = r1 * (1.0 + k1*(r1 * r1) + k2*(r1 * r1 * r1 * r1));
    float phi = atan(v.y, v.x);
    vec2 uv2 = vec2(0.5) + vec2(cos(phi), sin(phi)) * r2;
    fragColor = texture(iChannel0, vec2(uv2.x, uv.y));
}