One of the best personal projects I've seen. Good job!
amazing skill!! :)
Thanks for sharing!
A little over a year ago Peter Winslow started procedurally generating low poly planets as a part of his Poly Universe project. The project is a now a full-fledged civilization building game set in a universe of tiny worlds. The developer decided to share some of the lessons he learned from the development process. The tricks here are about writing the code for Unity, using C#, but you could also use the techniques for other engines.
Here is a piece of the first part to get you interested:
Step 1 — Generating a sphere.
The first step in procedurally generating a planet will be to create a round ball that we can mold into the shape of a planet. There are (at least) two good ways of going about doing this, and each one has its own advantage:
Creating a round ball, either by subdividing an icosahedron, or a square.
In the picture above, I’ve taken an icosahedron (that’s it in the upper left corner — you might recognize it as a twenty sided die), and I’ve broken each triangle into four smaller triangles. Then I did that again for each smaller triangle, until I ended up with a nice round sphere.
Below that I’ve done the same process, but starting with a square. Each face is broken into four smaller squares, the vertices are pushed and pulled until they are all equally distant from the center. That process is repeated until I again have something that looks like a sphere.
So which way is better? If you’re looking to use this in your own game, here is where you need to make a choice about aesthetics. If you start with a square, you end up with a sphere that is extremely easy to cover with a tiling texture. The sides of the cube have been pushed outward to make it look like a sphere, but it’s still possible to paint a tiling texture onto each original ‘face’ and have a seamlessly textured planet.
The downside of this method is that the geometry is ‘pinched’ around where the cube’s original faces met, and some of the polygons on the sphere are noticeably bigger than others. Since I’m pursuing a textureless style for my own project, I was able to avoid these problems by starting with an icosahedron, which generates a sphere with nearly uniform polygons (albeit one that would be more difficult to texture seamlessly).
Make sure to read the full guide here.