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
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
Please do not take into account that the second image is in mirror.