const float PI = 3.14159265; varying vec4 Color; varying float LightIntensity; const vec3 LightPosition = vec3( 2., 0., 10. ); void main( void ) { Color = gl_Color; vec4 pos = gl_ModelViewMatrix * gl_Vertex; float lenxy = length( pos.xy ); if( lenxy != 0.0 ) { float phi = atan( lenxy, -pos.z ); float r_over_len = ( phi / (PI/2.) ) / lenxy; pos.xy = pos.xy * r_over_len; } gl_Position = gl_ProjectionMatrix * pos; vec3 tnorm = normalize( gl_NormalMatrix*gl_Normal ); LightIntensity = dot( tnorm, normalize( gl_Position.xyz - LightPosition ) ); LightIntensity = abs( LightIntensity ); }