5
\$\begingroup\$

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

\$\endgroup\$
3
  • \$\begingroup\$ 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? \$\endgroup\$
    – House
    Commented Jul 16, 2012 at 13:24
  • \$\begingroup\$ yes, just how HDR shop does \$\endgroup\$
    – Sambatyon
    Commented Jul 16, 2012 at 13:32
  • \$\begingroup\$ Are you looking for an algorithm, library or software? \$\endgroup\$
    – msell
    Commented Jan 5, 2015 at 21:32

1 Answer 1

2
\$\begingroup\$

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);
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .