top of page
Search

Island Generator

  • Writer: Arjun Singh
    Arjun Singh
  • Jul 2, 2017
  • 3 min read

I think I found my Unity project. This low poly island is completely procedurally generated. It has everything you can ask for: Perlin Noise, Height Map, Chunks, Saturation Delaunay Triangulation, and more!

Since the last post, I have continued working on my low poly art in Blender. After a while it dawned on me, this is kind of easy. Why don't I translate the aesthetic into an algorithm? Yeah right. "Easy"

Moving on, I decided to google procedurally generated low poly landscapes and other buzz word filled search terms. Of course I'm not the only person who has looked this up. I came across all sorts of posts on Reddit that didn't make sense at the time. In all those posts one word stuck out. What's a Voxel? Low key sounds like a Pokémon.

Not at all. A voxel is like a bitmap but in 3D. It's the stuff Minecraft is famous for, the box world environment style. A link on one of the threads led me here. I followed it to about part 6. The ideas expressed were interesting but I'm not using 3D boxes and layers of terrain. When it comes down to it, all I want to do is make a curved shape out of triangles. I adopted the idea of generating chunks as a way to manage data, but it was time to move on.

I came across another Reddit post that mentioned the "Triangle World" problem. If you split your areas into hexagons and apply a height to the vertexes, you have a visual problem. All of the triangles look the same size and the hexagons appear to tessellate across your environment. That's less than desirable.

That led me to come up with my own solution, but not before I got some inspiration. The Polygon Map Generation article contained loads of information and algorithms. I explored one of the avenues, Delaunay triangulation, and came across Triangle.NET. Contrary to what many are saying I did run into errors upon installing. This guy walks you through solving those problems, if you are having trouble. After I heard about this convenient algorithm, I got the idea to randomly distribute a controlled number of points across the different chunks and keep a list of those points.

I triangulated my points and used OnDrawGizmos() to make sure the algorithm worked as intended with my set up. Once I was content with the 2D triangulation, I wanted to move to 3D triangulation. I played with a Perlin Noise library and incorporated my own math to create a satisfactory height map function. Every time I run the program, everything is randomized so I had to make sure that I was consistently happy with the results. Eventually I split the height map into elevation zones. At that point I knew it was time to move on to meshes.

After much trial and error, I successfully switched out OnDrawGizmos() with a mesh function. At runtime, a mesh is generated across all of the relevant points per chunk, and the mesh is colored accordingly. Ultimately it's the material that gives the faces the flat shaded property. This part was the most time consuming because I didn't know what I was doing. I just kept reading documentation and experimenting until I figured out how to get my meshes to display. The silliest bug (and probably most common) bug was the order in which I drew points. Normals are calculated according to the order you list vertexes. Don't make this mistake, just write a function that reorganizes the vertex order in every triangle.

I used Graphics Gail and a color combination generator to devise a color scheme for my textures. Despite this, the colors were all dull. I ended up discovering post processing effects Unity provides for free on the unity store. It's essential to get to achieve a vibrant/saturated appearance. An hour of post processing and voila you have an island generator.

It only took 15 days. This is coming from someone without much experience with Unity. If you apply your mind, you can achieve anything.

 
 
 

Comments


bottom of page