Skip to content

Latest commit

 

History

History

inverse-barrel-distortion

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Inverse Barrel Distortion

View shader on Shadertoy - Published on 2019-10-22

thumbnail

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;

Shaders

Image

Source: Image.glsl

Inputs

  • iChannel0: texture (mipmap, repeat, vflipped)

Links

License

The MIT License.