Sign in to follow this  
DumpAlien

Latitude/Longtitude to Cubemap transform

Recommended Posts

Hello guys! I have a 2D rectangular Latitude/Longitude map with a 2:1 ratio and I want to convert it into a cubemap. My math are really bad. Can you give me some tip of how to start? Thanks for your time! Cheers!

Share this post


Link to post
Share on other sites
You need to prepare the directions of all cubemap sample first, and then you lookup values from your Latitude/Longitude map using these directions. This is the easiest way to do the job. The downside is that not all samples from your Latitude/Longitude map are taken into account. So, the re-sampled cubemap may have some seams near the poles.

If those seams really bother you, you might want to do it the other way around. You prepare the directions and the solidangles of all Latitude/Longitude samples first. For each of these samples, you find its nearest cubemap texel using its direction. Its sample value weighted by its solidangle is accumulated to a cubemap, and its solidangle is accumulated to another cubemap. At last, you normalize the accumulated values using the accumulated solidangles. Please be careful that there will be cubemap texels didn't receive any values during the accumulation process. For these empty texels, you need to lookup values from your Latitude/Longitude map explicitly.

Alternatively, you can keep using the first approach but pre-limiting the signal frequency of the Latitude/Longitude map. However, filtering signal in spherical domain can be a dirty task. If tools are not immediately available, I don't think you want to go this way.

Alternatively, in case performance and memory consumption are not concerns, you can also use the first approach to re-sample a cubemap of exceptionally high resolution. High enough to correspond each Latitude/Longitude map sample to a distinct sample in cubemap. Afterward, you get the cubemap of your desired resolution from the high resolution cubemap.

[Edited by - ma_hty on August 17, 2009 12:26:43 PM]

Share this post


Link to post
Share on other sites
For each pixel in cubemap, find corresponding coordinate in lat/long coordinates. To do this,
1 - convert cubemap coordinate to 3d cartesian
2 - convert 3d cartesian coordinate to spherical (lat/long) coordinates.

The coordinate that you get will not lie exactly on the grid of lat/long values of your original map, so interpolate (use e.g. bilinear interpolation).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this