Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a cube map texture showing a surrounding area, which I want to pass to a program that only works with latitude/longitude maps.

How can I do this?

In other words, I need to turn this:

cube map texture

…into this (I think it's additionally rotated -90° over the x axis):

equirectangular texture

share|improve this question
You're saying you want to transform a cube map texture to fit on the inside of a sphere instead of the inside of a cube? – Byte56 Jul 16 '12 at 13:24
yes, just how HDR shop does – Sambatyon Jul 16 '12 at 13:32
Are you looking for an algorithm, library or software? – msell Jan 5 '15 at 21:32

With rect_coordinate ranging from -1 to 1 and assuming sin/cos functions take radian as inputs, for each pixel in the rectangular texture do:

color CubeToRectangle(vec2 rect_coordinate)
    vec3 cube_map_coordinate;

    cube_map_coordinate.x = cos(rect_coordinate.x * PI * 2) * cos(rect_coordinate.y * PI);
    cube_map_coordinate.y = sin(rect_coordinate.y * PI);
    cube_map_coordinate.z = sin(rect_coordinate.x * PI * 2) * cos(rect_coordinate.y * PI);

    return CubeMapTextureRead(cube_map_coordinate);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.