Retro games on a procedurally generated icosphere, built in Unity. More details coming soon!

Post feature Report RSS Onasphere - Planet Tech Demo

Here's an overview of how low-poly producerally generated planets are created in Onasphere.

Posted by on

On-a-sphere

The main playing surface of Onasphere is the sphere. It originally started as a simple Unity primitive, it then turned into a Maya model, and finally settled on a procedurally generated icosphere. This allowed me to generate an infinite number of new playing surfaces which I hope keeps the game more interesting.

Starting with nothing

Google is your friend. I feel that the best way to tackle a new problem is to first see if anyone else has already solved it. I started with a great post from Andreas Kahler that describes how to generate an Icosphere at runtime. The comments helped with some Unity/C# code and that was enough to get things started. I found some good Simplex Noise reference at Cabbynode Games and after evaluating a few other noise functions I found that it worked the best.

Simple Icosphere

I added some sliders for subdivision level and noise scale, frequency, and cutoff. This gave me a good set of basic tools for experimentation. Once I had gotten started I stumbled upon the game Caeludum by Tyler Hiemke who was doing some very similar things (although very different gameplay). He gave me some tips on vertex colouring for low poly which helped the overall quality.

Normal Smoothing

Adding the ability to do non-linear scaling allowed me to make things like asteroids.

Asteroid

Colliding

The collisions can either be simple spheres or a collision mesh. The collision mesh is generated using the same parameters of the sphere but with a bit of smoothing applied so that the resulting mesh isn't as jagged. Jaggies make for some nasty collisions!

Collision

Adding life

Now that I had a basic procedurally generated sphere I needed to add some life. This came in the form of colour, props, and atmospherics.I initially used vertex colouring for the triangles but, after hitting the 65k vertex limit in Unity, I decided to break up my mesh based on colour. For each of my planets I have a custom colour palette consisting of colours, materials, textures, and a cutoff threshold which can be swapped at runtime. I have recently added random colour generation based on colour theory.

Random Planet Colour

The next thing I added was layer based props which would be randomly placed depending on the previous colour layer. This is currently disabled but will eventually support buildings, trees, rocks, or whatever else makes sense.The last thing I added was water and atmosphere. They are both separate spheres with noise functions applied. The water has noise applied to the position of the vertices while the atmosphere has noise applied to the colour of the vertices to simulate clouds. The atmosphere isn't quite right yet so it's been disabled.

Putting a hex on it

Hexes are all the rage these days and I think they're pretty cool too. I was originally colouring things based on triangle but it resulted in some pretty odd looking configurations. When I was looking at Caeludum I noticed that it mainly used hexes for colour. Once I realized this it made total sense and I knew I had to add something similar. I scratched away in my notebook for a few hours and came up with a way to procedurally generate hex assignments for my spheres.

Random Hex

What's next?

I'm having a really hard time focusing on the gameplay because it's so much fun tweaking the planet. I think I could spend all my time making a random planet generator but that's not really the point of the game. A few things I would like to add in the future include: suns, gas giants, and crystalline planets.

Post comment Comments
Sph!nx
Sph!nx

Great read! Love these kind of articles. Keep them coming. :-)

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: