Island-Grass.jpg

For Izle I wanted to create a procedural world that could be entirely destroyed. I used voxels to create islands of different size, populated with AIs, props, and secrets.

Note: most of the screenshots on this page are taken directly from the Unity Editor, and do not use the in-game lighting, fog, camera lens effect, and environmental fx from Izle. As a result they can seem flat and technical. That’s normal!

 It works like this:

  • The world is split into chunks, sections and voxels (exactly like in Minecraft)

  • Voxels are filled with grass, dirt, ice, etc. with varying levels of fill to create smooth surfaces

  • Marching Cubes algorithm is used to generate a 3D mesh from the voxel structure

  • Generated 3D meshes can have physics and multiple materials

  • A list of surface voxels with their neighbour is built for custom pathfinding

  • All surface voxels have additional mini props like blades of grass or pebbles

  • Light is propagated from the sky and result is passed per-vertex to the terrain shader

  • Props are added on the surface, trees, AIs, chests, rocks, etc.

  • When an island is built next to another island a bridge is generated between them

Other features:

  • Caves inside the island can be added with a random path to the surface

  • Textures can be used to add vertical terrain to create layered hills or maze walls

  • Textures can be used to remove land and create an island broken into pieces

Final result with debug information shown for one section:

Finding the right mathematical functions and noises to generate the island can be quite difficult:

  • We need a noise for the edge of the island to avoid having a dull cone shape

  • We need another noise for the surface elevation, in the example above I went for a slow perlin noise to simulate rolling hills

  • And we need a third noise for the rocky surface for the parts below made of dirt

  • Some other islands use additional noise to add or remove terrain, create rocky soil, etc.

Tools

I created a series of tool inside the Unity Editor to test and debug the voxel engine. This allowed me to generate any type of island, and build on them. It generates everything from the terrain to the props, lighting, pathfinding and AIs.

This is very useful to test atomic functions, stress test the engine, and inspect voxels to make sure everything is going according to plan.

Modifying The Terrain

When the terrain is modified, meshes are re-generated and light is re-propagated. All happening in less than 1ms! This is why the world needs to be split into chunks and sections, so that we only re-generate very small parts of the world, hopefully just one section or two.

Part of the mesh generation and light propagation algorithms can be multi-threaded and streamed over a few frames if needed. Which is something I do when entire islands made of millions of voxels are generated in real-time.

Tech5.jpg

It’s possible to modify the terrain in real-time by changing the content of each voxel and regenerating some sections, here you see the entrance of a tunnel built by the player.

Tech6.jpg

Underground areas can be large, example of a slice of the first island. The area under the island with the 4 columns is a place you must reach by digging into the ground, it’s part of the digging & building tutorial.

Light

The light propagation model I used is quite simple. Light comes vertically from the sky and tries to propagate to neighbouring voxels, slowly losing intensity.

The complicated part is when we modify the terrain in real-time because we cannot re-propagate the light of every voxel, it would be too costly. We need to decide on which sections (and voxels) to re-compute the light, and this can be a bit tricky because in the worst case just a small hole into a roof can bring light into large areas.

The per-voxel light information is then stored per-vertex in the generated mesh and used by the terrain shader to lighten and darken areas.

Tech7.jpg

Here is an image of the light information contained in each voxel of a section for the entrance of the tunnel. The white voxels are entirely disconnected from the sky, as a result they slowly lose light. The red voxels are directly lighted from the sky. Blue and green voxels are starting to lose light and represent the transition between outdoor and indoor and are used to change the atmosphere and lighting in-game.

Castle Creative Process

To finish this article I wanted to share some bits from the creative process to make the Castle Island.

Castle1.jpg

I started from the Hills Island, and created white stone voxels that I generated in a circular fashion on top of the island. We probe around the surface voxels to find the pillar position and then generate walls between them.

Castle2.jpg

I then added crenellation to form battlements on the walls and towers.

Note that there is an opening because at first I thought the player would need it, but I then realized that having no opening would be much better. No clear entrance forces the player to either dig into the walls, or build a staircase, using the sandbox elements of the game to overcome the challenge.

Castle2-InGame.jpg

Feeling of the Castle in-game. Seen from the neighbouring Forest Island. A bridge is visible linking the two.

Bridges are important separators for Level of Detail (LoD) and to load / unload data. You cannot keep millions of voxels in memory forever!

Castle3-Bug.jpg

Screenshot from 11pm, something must have happened.

Castle4.jpg

I changed the base terrain elevation to have the central part of the castle on a hill and to make sure the walls where not inside a slope.

Added a door to the inside section (that was later removed), and a blue cone for the highest tower. Walls can have very thin windows too, like real medieval castles!

Castle4Bis.jpg

Added some vertical flag props on half of the low towers, and a random number of high towers. Each castle is unique!

Island-Ice.jpg

Later in development the Castle Island was converted into an Ice Castle, to have an island of each element into the demo. You can see I changed the noise making the surface and bottom part of the island too to give it an icy look.

I wonder what this could be inspired from?

I wonder what this could be inspired from?

Voxel Engine Programming - Alexis Bacot
3D Art - Robert Heng & Reynald Bayeux
2015

Previous
Previous

Izle

Next
Next

Enter The Brain