Advertisement
Guest User

Untitled

a guest
Jun 15th, 2010
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. attribute float cameraPosX;
  2. attribute float cameraPosY;
  3. attribute float cameraPosZ;
  4.  
  5. in vec4 MCvertex;
  6.  
  7. out float sphIndex;
  8.  
  9.  
  10. void main()
  11. {
  12.  
  13.     vec3 cartesian;
  14.     vec3 spherical;
  15.    
  16.     vec3 v = vec3(MCvertex);
  17.     vec3 cameraPos;
  18.     cameraPos.x = cameraPosX;
  19.     cameraPos.y = cameraPosY;
  20.     cameraPos.z = cameraPosZ;
  21.    
  22.    
  23.     vec3 cameraDir = normalize(v - cameraPos);
  24.    
  25.     spherical.x = 1.0;
  26.     spherical.y = acos(cameraDir.z / sqrt(cameraDir.x*cameraDir.x +
  27.                         cameraDir.y*cameraDir.y +
  28.                         cameraDir.z*cameraDir.z));
  29.     spherical.y = spherical.y * 180.0 / 3.14159265;
  30.    
  31.     spherical.z = atan(cameraDir.y,
  32.                 sqrt(cameraDir.x*cameraDir.x + cameraDir.y*cameraDir.y));
  33.     spherical.z = spherical.z * 180.0 / 3.14159265;
  34.  
  35.    
  36.     sphIndex = (spherical.y*179.0 + spherical.z) / (180.0*180.0);
  37.    
  38.     gl_Position = ftransform();
  39.    
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement