   mapping a heightmap to a sphere
  how do I convert coordinates on a unit sphere into latitude and longitude or 2d values that I can use to do a lookup in a heightmap?   
  lng = atan2(y, x);lat = atan2(z, sqrt(x*x + y*y));   ;  thank you   ;  I'm not sure what you are using this for but you may not get the results you want unless you are careful with your heightmap. Remember the polls will be compressed and there will be a seam on one side of your sphere unless you do stuff to correct for these issues.   ;  I am aware of the pole issue and am avoiding it by using a deformed cube and careful creation of the heightmaps. I just find it impractical to use 6 maps instead of 1. 30 or so moons and 1 planet will take a ton of memory at high detail. I prefer to not have to render everything around the user as a background instead of real-time. Though when the user is traveling at conventional speeds they won't really notice. I had tried storing the noise with the vertex data using geometry shaders and stream out, but the seams of the noise drift apart as the object gets bigger so a height map seems the only viable answer other than per pixel perlin noise.   ;  Wasn't able to make it work, but this did. It converts 3D unit sphere coords to x,y in the range of 0-1.Out.UV.y = Out.Position.y;Out.UV.x = degrees(dot(float4(0,0,1,0),Out.Position))/180;Out.UV.x = saturate((Out.UV.x + 1)/2);Out.UV.y = saturate((Out.UV.y+1)/2);   ;  If you insist on using 1 texture, your planets will look like crap at the poles.   