# Latitude/Longtitude to Cubemap transform

This topic is 3325 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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).

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632630
• Total Posts
3007525
• ### Who's Online (See full list)

There are no registered users currently online

×