float2 CartesianToSpherical(float x, float y, float z) { float2 SphericalPos; SphericalPos.x = atan2(x,z)/6.28318f; if(SphericalPos.x < 0.0f) SphericalPos.x += 1.0f; SphericalPos.y = atan2(sqrt(x*x+z*z),y)/3.14159f; return SphericalPos; }