attribute float cameraPosX; attribute float cameraPosY; attribute float cameraPosZ; varying vec4 MCvertex; varying float sphIndex; void main() { vec3 cartesian; vec3 spherical; gl_Position = ftransform(); vec3 v = gl_Position.xyz; vec3 cameraPos; cameraPos.x = cameraPosX; cameraPos.y = cameraPosY; cameraPos.z = cameraPosZ; vec3 cameraDir = normalize(v - cameraPos); spherical.x = 1.0; spherical.y = acos(cameraDir.z / sqrt(cameraDir.x*cameraDir.x + cameraDir.y*cameraDir.y + cameraDir.z*cameraDir.z)); spherical.y = spherical.y * 180.0 / 3.14159265; spherical.z = atan(cameraDir.y, sqrt(cameraDir.x*cameraDir.x + cameraDir.y*cameraDir.y)); spherical.z = spherical.z * 180.0 / 3.14159265; sphIndex = (spherical.y*180.0 + spherical.z) / (180.0*180.0); gl_TexCoord[0] = gl_MultiTexCoord0; }