I would like to render my scene with a wide FOV and then apply a fisheye distortion via fragment shader. How would this shader best be implemented?
Update
I try to reproduce a fisheye effect similar to what can be seen through a lense like this one. My first try was to port the fragment shader explained in How do I create a wide-angle / fisheye lens with HLSL? because it seemed to be a good starting point:
#version 120
uniform sampler2D src;
float fov = 2.09;
void main(void)
{
float z = sqrt(1 - gl_TexCoord[0].s * gl_TexCoord[0].s - gl_TexCoord[0].t * gl_TexCoord[0].t);
float a = 1.0 / (z * tan(fov * 0.5));
gl_FragColor = texture2D(src, (gl_TexCoord[0].st - 0.5) * 2.0 * a);
}
unfortunately, the result looks like this: 