Advertisement
Guest User

Untitled

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