Sign in to follow this  
Numsgil

Heightmapping a sphere

Recommended Posts

I'm working on a game where the heightmap is determined at run time from user inputs. I know the standard method of applying a texture to a sphere, which results in the poles having more sampling points. I'd like to expore other options that are better suited to the surface of a sphere than a rectanglular grid. I'm trying to find a method that satisfies the following criteria: 1. More or less equal sample points for an area of any arbitrary longitude or latitude. 2. A well defined and easy to calculate neighborhood for any given sample point. In the same way that a regular 2D square grid has well defined neighbors. (Neighborhood(x,y) in a 2D grid is the set of points such that x is in {x-1, x, x+1} and y is in {y-1, y, y+1}) 3. A method that makes it easy to calculate the value of any given data point. A 2D regular grid is easy, since you just have an array of arrays. I can imagine some tree structures that would make you traverse the tree to find the values of certain data points, which isn't a good solution. Hope I've been clear so far. I'm thinking of a geodesic sphere or something similar. I'm not sure how to represent the data points of the sphere in memory. Since it doesn't need to be stored in any sort of image format, alot of possibilities open up I think. Just interested in some outside opinions. [Edited by - Numsgil on November 11, 2006 10:25:43 PM]

Share this post


Link to post
Share on other sites
My coworker solved how to map a cube to a sphere. It works pretty well, check it out here

http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html

Share this post


Link to post
Share on other sites
Gotta love the internet. I spent my weekend trying to turn a cube into a sphere (with not very pleasing results) through trial and error and very little maths, then browsing Gamedev during my lunch break on Monday I find exactly what I need.

Share this post


Link to post
Share on other sites
Quote:
Original post by ph33r
My coworker solved how to map a cube to a sphere. It works pretty well, check it out here

http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html


Wow, that's a lot of maths. Personally i'm just normalizing and rescaling by the radius each vertex in the grid of each face of the cube. What's the advantage of your method ?

Y.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ysaneya
Quote:
Original post by ph33r
My coworker solved how to map a cube to a sphere. It works pretty well, check it out here

http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html


Wow, that's a lot of maths. Personally i'm just normalizing and rescaling by the radius each vertex in the grid of each face of the cube. What's the advantage of your method ?

Y.


...that's not really a lot of math. ...Are you looking at the proof and saying that(even if you are, that still isn't very much math....probably took 10 minutes to perform that transformation once he had his theory correct)
x' = {x*((sqrt)(1-((y*y)/2) - ((z*z*)/2) + ((y*y*z*z)/3)}

that computation isn't very expensive at all considering the millions of other methods.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ysaneya
Quote:
Original post by ph33r
My coworker solved how to map a cube to a sphere. It works pretty well, check it out here

http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html


Wow, that's a lot of maths. Personally i'm just normalizing and rescaling by the radius each vertex in the grid of each face of the cube. What's the advantage of your method ?

Y.


Using you're method you'll get a higher distribution of vertices near the corners of the cube.

Share this post


Link to post
Share on other sites
What if you read the information from the height map as elevations of latitude and longitude? That way the map is already in spherical coordinates and the duplication of the vertices would be at the poles.

Share this post


Link to post
Share on other sites
You want to minimize the number of data redundancy at the poles. Using longitude/latitude has this problem. There are a number of visual artifacts that can become noticable if you do this, among other, more subtle issues.

From what I can see, the cube to sphere mapping works reasonably well and is easy enough to use. Most programmers are well accustomed to handling square (and cube) data structures.

Spherical geodesic grids seem to be a better method, especially if you're running various kernels on the data (such as erosion), but the data structure is a little more difficult to deal with.

I'll experiment with the geodesic grids, and if it's too difficult to set up a class to encapsulate the complexities I'll move to the cube to sphere mapping.

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