Jump to content
  • Advertisement
Sign in to follow this  
c_olin

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!