Article index
- 1 – Fish Eye Shader
- 2 – Barrel Distortion Shaders
- 3 – Dome Distortion Shader
- 4 – Another Very Cool Fish Eye Shader
- 5 – Shadertoy FishEye / Anti-FishEye Shader
- 6 – Fish Eye Lens Shader
3 – Dome Distortion Shader
This shader is based on the following links:
- Realtime Dome Imaging and Interaction: Towards Immersive Design Environments
- GPU Programming for Dome Projection
Dome projection requires a fish eye projector lens, which necessarily distorts the image. A fisheye lens is needed for the projector to display across the nearly 180° of the dome. This necessarily introduces a distortion of the graphics that is being displayed through it. The trick is to then “pre-distort” the graphics in the opposite direction before sending it on to the projector.
The following GLSL program (which is not a post processing filter because it directly acts on the 3D object) shows the pre-distort effect:
Vertex shader:
#version 120 varying vec4 Vertex_UV; uniform mat4 gxl3d_ModelViewMatrix; uniform mat4 gxl3d_ProjectionMatrix; uniform int do_distorsion; const float PI = 3.1415926535; void main() { vec4 P = gxl3d_ModelViewMatrix * gl_Vertex; if (do_distorsion == 1) { float rxy = length(P.xy); if (rxy > 0) { float phi = atan(rxy, -P.z); float lens_radius = phi * 180.0 / PI * 2.0; P.xy *= (lens_radius / rxy); } } gl_Position = gxl3d_ProjectionMatrix * P; Vertex_UV = gl_MultiTexCoord0 * 10.0; }
Fragment shader:
#version 120 void main() { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); }
Dome distortion enabled
Dome distortion disabled
Article index
cool shaders! I especially like Fish Eye Lens Shader.
check this shader
http://www.vill.ee/entry.php?13-Romanesco-broccoli-pattern-2D-shader