Planet Generation

Forum Elaboration

There are two common ways to generate planets that won’t drive the programmer who takes it on mad.

The Quad Sphere and The Icosphere

The Way of the Past
The Quad Sphere is the classic way you see in Spore. You take a cube, you texture it, apply various data to it through maps, then turn it into a ball. End result is a fairly triangle efficient planet. The issue is this method has problems with seams, map glitches, corruption, file bloat (lots of images compared to the competition) and it was only done for one reason and one reason only.

Old GPUs used to struggle really hard with high triangle counts. I am not lying to you when I say modern integrated graphics are better than some dedicated stuff from back then at this. Modern computers and GPUs can almost draw triangles as easily as pixels, the problem arises when triangles are smaller than pixels or, in the case of software like Blender 3D, triangles are stored in RAM for manipulation.

But what makes Quad Spheres good for Spore but no good for us? Problem back then was the other competing method is an inefficient proposal in terms of triangle count as when you would subdivide it (make the triangles smaller, allowing that seamless zoom into a planet surface), you would get lots more triangles than when you applied such operations to a Quad Sphere. Couldn’t have that on a 2005 desktop. So, games like Spore which begun development in the early 2000s decided to use Quad Spheres and that’s what eventually spread. However, if you really need convincing:

  • You can’t map the surface of a Quad Sphere without image processing for the maps and textures that give it shape and features. For us that would mean writing graphics programming and writing shaders. Many of them. Ugly ones.

  • The shape a Quad Sphere comes from is a cube, so when you do various operations, you always have to keep this in mind.

  • You can’t reuse a lot we’ve done so far in terms of pathing or placement. The Quad Sphere would need logic for traversing a sphere or converting UV coordinates (2D surface coordinates) to usable units

  • Selecting spots on a Quad sphere requires either that UV / Sphere Math nonsense again, or some whole new interaction system we haven’t wrapped our minds around yet.

The Icosphere
In computer graphics, the Icosphere is a very special shape. It comes from the largest Platonic Solid (of which there are 5 in the universe, every face is the exact same size), the Icosahedron. In computer graphics this is big money huge because the means you can deform it in any direction with predictable results and you can subdivide it easily and reliably. It can also be truncated (snip off every pointy corner, that’s what truncation does) into another useful shape, The Hexasphere. The Hexasphere is, as you would guess, a sphere made out of hexes, and though it looks different, it has the exact same triangle layout as a Icosphere (because it secretly is one).

Fun Fact: there are 12 pentagons on a hexasphere no matter the number of hexes

Unfortunately, only a few projects have ever harnessed the power of the Icosphere so there are limited things to view out there that truly show their capability. Besides those who needed Hexaspheres like the game Rim World. Here are some advantages demonstrated by Rim World we may like:

  • You can use hex math to do everything on the surface of an Icosphere. Everything. In Rim World, Caravans will auto path their migrations, roads will be built, and all manner of insane things be placed purely by referencing and calculating positions on the hex grid that is the Icosphere surface.

  • You can smoothly subdivide it when you zoom in, the thing is you will be subdividing a giant triangle the closer you get to the surface (which is easy but worth knowing about) rather than a plane like on a Quad Sphere.

  • Quite compact and so is the data. The hexasphere you use to abstract positions of the surface to the player, abstract positions to yourself to use coordinates, and the shape you subdivide and mold into valleys and mountains and seas, are all one shape.

The Considerations
If I have convinced those reading that the Icosphere is shamelessly superior (it is) there are considerations. There are specific ways things must sometimes be done when it comes to handling the Hex state and the Ico state. Stretching shouldn’t really be done unless you’re willing to write warp code to un-stretch things. You can’t go modifying the Hexasphere in elaborate ways as if it exists in isolation from the Icosphere, whenever you do something, you must consider how you preserve the compactness of having one shape fill 2 roles. In general, the simpler the better. Also, it’s worth noting the Icosphere is, although a simple thing to wrap the mind around once you understand it, horribly documented. It is however, very modular and flexible.

Start small, end fantastically.

4 Likes