Skip to content
Snippets Groups Projects
Commit c091383a authored by slevy's avatar slevy
Browse files

Simple vertex shader for dome rendering.

parent 9d998cd3
No related branches found
No related tags found
No related merge requests found
#version 110
// uniform parameters
float zoom = 1.0;
float tilt = 45.0;
const float pi_2 = 1.5707963267949;
float Pzz = gl_ProjectionMatrix[2][2];
float Pwz = gl_ProjectionMatrix[3][2];
float nearclip = Pwz / (Pzz - 1.0);
float aspect = gl_ProjectionMatrix[0][0] / gl_ProjectionMatrix[1][1];
float xstretch = (aspect < 1.0) ? aspect : 1.0;
float ystretch = (aspect > 1.0) ? 1.0/aspect : 1.0;
float stilt = sin(radians(tilt));
float ctilt = cos(radians(tilt));
void main() {
vec4 p = gl_ModelViewMatrix * gl_Vertex;
float yt = p.y*ctilt - p.z*stilt;
float zt = p.z*ctilt + p.y*stilt;
float r = sqrt(p.x*p.x + yt*yt);
float arc = atan( r / zt );
float w = (zt < -nearclip && abs(arc) < pi_2) ? pi_2*zoom : -pi_2*zoom;
float arc_r = arc / r;
gl_Position = vec4( xstretch * p.x * arc_r, ystretch * yt * arc_r, 0.5, w );
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment