Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // vertex shader
- attribute float cameraPosX;
- attribute float cameraPosY;
- attribute float cameraPosZ;
- varying float sphIndex;
- void main()
- {
- vec3 cartesian;
- vec3 spherical;
- vec3 v = vec3(gl_Vertex);
- vec3 cameraPos;
- cameraPos.x = cameraPosX;
- cameraPos.y = cameraPosY;
- cameraPos.z = cameraPosZ;
- gl_Position = ftransform();
- 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(spherical.z, spherical.y);
- spherical.z = spherical.z * 180.0 / 3.14159265;
- sphIndex = (spherical.y*180.0 + spherical.z) / (180.0*180.0);
- }
- // fragment shader
- attribute float cameraPosX;
- attribute float cameraPosY;
- attribute float cameraPosZ;
- varying float sphIndex;
- void main()
- {
- vec3 cartesian;
- vec3 spherical;
- vec3 v = vec3(gl_Vertex);
- vec3 cameraPos;
- cameraPos.x = cameraPosX;
- cameraPos.y = cameraPosY;
- cameraPos.z = cameraPosZ;
- gl_Position = ftransform();
- 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(spherical.z, spherical.y);
- spherical.z = spherical.z * 180.0 / 3.14159265;
- sphIndex = (spherical.y*180.0 + spherical.z) / (180.0*180.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement