itch.io is community of indie game creators and players

Devlogs

Terrain

Bad Pixels
A downloadable infernal game for Windows and macOS



One of the questions in any Unity game is how do you go about making a terrain. There is a terrain engine built-in, however it is notoriously "one-size-fits-all"... if you are making a standard walk-em-up in a forrest, that built-in terrain engine is perfect.

Bad Pixels is a little different, we are using custom shaders all over the place and a custom solution was needed to show the blocky grid.

Building the terrain engine for Bad Pixels has some unique things going on to help it look like it came from the days of old. Here are some of the major features:


Lighting & Vertex Smoothing
In Unity, any dynamically created mesh gets vertex smoothing applied automatically. In this case, the mesh generation needed to be broken up so that lighting can fall in shaded chunks instead of gradients. Speaking of gradients...



Height Colouring

Usually, when colouring a terrain mesh, the standard approach is to colour using a texture. Since Bad Pixels doesn't use textures, I needed to colour heights by vertex color. However, vertex colors get blended into one another when you do this, so I needed to change the mesh generator to color by face.



Rivers and Roads -> maps

How to reliably add rivers and roads? (and railroads) Luckily this a standard game development feature, a render texture can be used to control the height of the terrain. Bad Pixels updates this in realtime...



Deformable Terrain!

This is the major feature of Bad Pixels terrain. Ever wish when you chuck some TNT in a game, that it actually changed the game's terrain? Gone are impact marks on an otherwise unscathed bit of static geometry. In Bad Pixels, blowing stuff up is a key part of the game. Terrain changes stay too, so if you happen to revisit this particular level, the damage you, or others caused, remains.


Object Placement

Placing every single bush, rock and snake by hand might be a bit laborious so within the terrain engine, certain objects appear at certain heights. For example, rocks appear more on higher ground, bushes appear more where water is in the soil, and snakes appear in your boots.

Download Bad Pixels
Read comments (9)