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

Use a matrix for the tilted camera stuff.

parent c091383a
No related branches found
No related tags found
No related merge requests found
......@@ -18,16 +18,21 @@ float ystretch = (aspect > 1.0) ? 1.0/aspect : 1.0;
float stilt = sin(radians(tilt));
float ctilt = cos(radians(tilt));
mat4 Ttilt = mat4( 1.0, 0.0, 0.0, 0.0,
0.0, ctilt, -stilt, 0.0,
0.0, stilt, ctilt, 0.0,
0.0, 0.0, 0.0, 1.0 );
mat4 TtiltModelView = Ttilt * gl_ModelViewMatrix;
void main() {
vec4 p = gl_ModelViewMatrix * gl_Vertex;
float yt = p.y*ctilt - p.z*stilt;
float zt = p.z*ctilt + p.y*stilt;
vec4 p = TtiltModelView * gl_Vertex;
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 r = sqrt(p.x*p.x + p.y*p.y);
float arc = atan( r / p.z );
float w = (p.z < -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_Position = vec4( -xstretch * p.x * arc_r, -ystretch * p.y * 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