# Morphing a cube to a sphere...

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

## Recommended Posts

I am coding a simple planet renderer. I have read multiple papers on rendering planets with 6 quadtrees morphed into a cube, but none have mentioned the distortion I am getting with mine. Here are some screenshots of 6 quadtrees split in various stages with all of their points normalized. As you can see, there is a lot of distortion on the sphere, which I was expecting. But I was under the impression that there is a way to minimize this distortion. However I have been searching for quite awhile but I have found nothing. I was hoping some of you might know. Thanks

##### Share on other sites
The problem is that a sphere and a plane are not isometric, which means that some sort of distortion will always exist (a projection cannot preserve both angles and areas). Cartographers have studied this problem extensively, and there are some projections that behave much better than the one you are using. My favorite is probably the Peirce quincuncial projection, which is conformal (preserves angles) and maps the sphere to a square.

##### Share on other sites
Thanks for the reply. Although after a quick read through that Wiki entry it is not entirely clear how I would implement it. I'll do some research.

##### Share on other sites
If you start with a polyhedron, there will be distortion near what began as the vertices of the polyhedron. I've played with this (and written programs that produce almost exactly the same sort of output as you are showing), and I've observed that there seems to be a kind of "conservation law," where, if you start with more vertices, then the distortion is "spread out" more between the larger number of vertices (although I have no rigorous mathematical understanding of this).

The upshot of this is that, if you begin with a regular icosahedron (instead of a cube) and subdivide its faces (equilateral triangles... You subdivide each triangle into four by creating new vertices at the midpoints of the edges and connecting them with new edges), this looks better than if you begin with a cube.

See this page on Platonic solids for a reference. Specifically, they give coordinates for the vertices of an icosahedron (and look at Craig Reynolds' code).

##### Share on other sites
I've looked into different methods starting from other shapes rather than cubes as you suggest. The thing is that using a cube simplifies a lot of problems because quadtrees adapt perfectly with it. Although using other shapes could minimize distortion, it would maximize the complexity of my LOD and culling algorithms.

I find as I get closer to the sphere and the nodes get subdivided the distortion seems to get less and less.

##### Share on other sites
What do you mean by "distortion" actually? Is it talking about the shape? Is it talking about the solid angle? Or...

##### Share on other sites
The distortion I'm talking about is in each of the quads. My goal is for each quad to be a perfect square. Obviously this is impossible when morphed to a sphere. What I am looking for is another way of projecting a cube to a sphere that might keep each quad more regular.

The reasoning behind this is that each of those quads represents a quadtree node which will contain terrain geometry. The terrain geometry may be pretty distorted on the quads with distorted size.

##### Share on other sites
You might like to try this technique - I have had some success with it, and I believe Ysaneya was using it for his planets as well.

##### Share on other sites
Quote:
 Original post by swiftcoderYou might like to try this technique - I have had some success with it, and I believe Ysaneya was using it for his planets as well.

Exactly what I was looking for... Thanks very much.

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633696
• Total Posts
3013393
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!