Skip to main content
GameDev.net gamedev.net
🔒 Locked

Camera setup for panorama image

Started by OrangyTang Jun 20, 2011 at 4:52 PM 2 replies 2.4k views
Original Post
OrangyTang
OrangyTang
[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]
alvaro
alvaro
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);
}
}
alvaro
alvaro
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.




Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.