how do you map a sphere to a cube

649 Views Asked by At

I want to map a sphere to a cube in order to create a panoramic tour like the one given here

But I don't know how can you obtain images like enter image description here

This image is one of the cube's faces.

What I tried was to take the view ray, and determine the intersection between the viewray that passes trough a point on the sphere and the face of the cube that in inscribed into the sphere. But the result I get looks like

enter image description here

Please do not take into account that the second image is in mirror.