Search code examples
opengl-esthree.jspanoramas360-virtual-reality360-panorama

Convert panorama to VR (equirectangular or cubemap)


I have an image that is a panorama 360 photo (example). I'd like to convert it to a format that fits in VR - either equirectangular (example) or cubemap.

The only solution I've seen is http://ggnome.com/pano2vr but it does not seem to work for me. Is there a different approach I can take?


Solution

  • I went ahead a wrote a C++ application that (hopefully) does what you want and posted it on GitHub.

    Given the cylinder x^2 + y^2 = 1 inscribed inside a 2x2x2 cube centered at the origin, we can project the cylindrical panorama onto the coresponding four faces of the cube as follows. For every pixel in the output image we cast a ray from the cube's center at (0,0,0) through the corresponding point on one of the cube's faces and determine where that ray intersects the cylinder. We then map this point on the cylinder to the corresponding point in the input image and (bilinearly) sample the input image at the point. The resulting pixel color is assigned to the current output pixel.

    You can read the gory details in the associated docs.

    Here are some thumbnails of the input and output image you suggested:

    enter image description here enter image description here