5
$\begingroup$

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.

  • 0
    I edited the question alot, and uploaded other images so I hope I can get more answers. Please take a look again2011-11-30

1 Answers 1

0

Not sure if you're still looking for an answer at this point but I think I have one. If you have the x, y, and z components of a point on the unit sphere, then dividing each point by the maximum absolute value of the coordinates will take you to a cube centered at the origin ($[-1,1]\times [-1,1] \times [-1,1]$).

What I think you're trying to do is, given a camera position, send a ray through each pixel on a screen, and given that ray's direction, return the appropriate color for the pixel based on the images.

Assuming you're constructing each scene out of six images - up, down, left, right, front, and back - what you're trying to create is known as a cubemap in computer graphics. There's is probably a lot of software out there for generating cubemaps based on images. I've never written software like this myself but if I had to guess all it involves is taking the unit vector which represents a pixels direction, applying the map I described in the first paragraph which gets you on the cube, and from there just identify which face of the cube it's on, and do an orthographic projection to get the necessary coordinates to sample the image.