Camera setup for panorama image

Started by
2 comments, last by alvaro 12 years, 10 months ago
[font="Arial,"][size="4"]I have a 3d landscape that I'd like to convert into an equirectangular panorama image (more specifically, one that I can plug into google maps like this: http://code.google.c...eatingPanoramas ).

[size="4"]Normally I'd just render out a cubemap. However google maps doesn't want a cubemap, and I can't see a good way of converting from a cubemap to an equirectangular projection.

[/font][font="Arial,"][size="4"]Does anyone know what camera positions I'll need to render out an equirectangular image? Thanks.

[/font]
[font="Arial,"]Edit: should probably say that I'm doing the rendering with plain old fixed-function opengl, so I'd like to figure out how to do this without needing shaders. It doesn't have to be 100% accurate though.[/font]
Advertisement
You can convert from a cubemap to a spherical map fairly easily. The code would look something like this:

for (int j=0; j<V_RES; ++j) {
double latitude = (double(j)/V_RES-0.5)*PI;
double z = sin(latitude);
for (int i=0; i<H_RES; ++i) {
double longitude = (double(i)/H_RES-0.5)*2.0*PI;
double x = cos(latitude)*sin(longitude);
double y = cos(latitude)*cos(longitude);
spherical_map[j] = pick_from_cubemap(cubemap,x,y,z);
}
}
I must be being a little slow - how does the pick_from_cubemap go from an x,y,z to a cube face and an x,y position?
Well, a cubemap is six images. You first find which coordinate of the three has the largest absolute value and you check its sign. These two pieces of information tell you which face you are at. The easiest case is that where z is largest and positive. You would then compute X=x/z, Y=y/z, which is how you project to the plane z=1. The coordinates (X,Y) are now between -1 and 1. The details of how to map that square to the coordinates in your cubemap depend on how you have arranged the faces.

I figured you already knew how to do this, if you were using cubemaps... Let me know if it's still not clear enough.




This topic is closed to new replies.

Advertisement