Morphing a cube to a sphere...

Started by
7 comments, last by c_olin 15 years, 5 months ago
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
Advertisement
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.
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.
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).
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.
What do you mean by "distortion" actually? Is it talking about the shape? Is it talking about the solid angle? Or...
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.
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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
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.


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

This topic is closed to new replies.

Advertisement