After extensive search, I have not been able to find a decently explained formula for WebGL fisheye image correction. A Shadertoy at fisheye/antifisheye shows a formula
uv = m + normalize(d) * atan(r * -power * 10.0) * bind / atan(-power * bind * 10.0);
which is literally described as "weird formula". It somehow follows Paul Burke's work on lens distortion correction here, but I do not see the connection. In my application, the formula boils down to (values are hand-tuned to my lens and webcam):
uv = centerPoint + normalize(d) * atan(r * pi) * 1/3 / atan(pi/3)
Where r is the distance of a pixel from center of the image, d is the unit vector in that direction and centerPoint is, well, the center of the image. I don't understand how can the arctangent be tied directly to the coordinates, can anyone help me get it? I do get that the part of the formula with arc tangents is calculation of pixel distance from the image center, what I do not understand is how is that computed.
Thanks!