This page is created automatically. Click here to view this shader on Shadertoy.
The inverse of a Barrel Distortion.
I couldn't find this function online, so I derived it myself. A surprisingly complex formula ;-).
uv -= .5;
float b = distortion;
float l = length(uv);
float x0 = pow(9.*b*b*l + sqrt(3.) * sqrt(27.*b*b*b*b*l*l + 4.*b*b*b), 1./3.);
float x = x0 / (pow(2., 1./3.) * pow(3., 2./3.) * b) - pow(2./3., 1./3.) / x0;
return uv * (x / l) + .5;
Source code
You can find (the full source of) Inverse Barrel Distortion on Shadertoy.