main
open_to_work
Voxel Terrain Editing
Voxel Terrain Editing

The Problem: terrain modding was only achievable with player terrain
Animalkind uses a voxelized terrain system that operates via signed distance fields and a marching-square algorithm, and initially terrain was authored by baking height maps into voxel data to create the base terrain shape. Because height maps are two-dimensional and only capable of encoding a height change from a single top-down perspective, naturalistic terrain with realistic angle changes and indents like caves and overhangs are structurally impossible. To overcome this, caves and other details were added via terrain-editing tools that were initially created so players could edit the terrain themselves. This allowed caves and other geometry to be added into the larger bulk structure, but came with significant limitations and a very high degree of friction. Adding details to worlds was time consuming, inelegant, and was strictly limited by mechanics we'd tied to player objects, and thus lacked a traditional edit-feel.
modifying terrain with the player tools limited us to player movements, meaning most feature changes were flat, uninspired, and took forever to author
The Solution: turning player tools into editor tools
In order to increase the speed, accuracy, and flexibility of our editing tools, it became clear that breaking outside of this player-flow was necessary. Rather than build or rely upon a parallel editor that lives outside of Unity or this framework, I instead decided that the most-reliable way to know what our terrain would look like at runtime was to actually author it within the same functional system as our game. To that effect, I pulled our current player tooling out of the player space and into the editor space with two #if UNITY_EDITOR entry points to our existing ChunksManager and routed editor brush operations through the exact same modifyVoxelField path that the player tools utilized. Thus, the editor isn't a special case here, but rather the same machinery entering through a different door. Every fix, adjustment, and feature expansion made to the core pipeline propagates both to the player tools and the editor system simultaneously, keeping them in line and centralized.
How do you turn player tools into editor tools? Very very carefully.
The Result: infinitely tunable editor tools with custom SDF brushes
The result is a full brush-based sculpting system supporting our core features, and some new ones: dig, add, smooth, level, paint, roughen, an SDF stamp brush that accepts arbitrary signed distance field shapes with configurable orientation, scale, and strength, and a history brush that serves as a reliable "undo" feature. The SDF tool in particular required resolving a sequential chain issues, the most significant being the gradient artifacts that also impacted the other tools, with each fix exposing another issue. This deeply overhauled our previous terrain editing pipeline, made terrain adjustments more accessible to the wider development team, unlocked a workflow that was more legible to world designers, and collapsed innumerable processes that often took hours to produce worse results into a singular action that took mere minutes and was infinitely more flexible, saving hours of effort just within its first week of implementation by allowing us to do things like instantly delete unsightly terrain from our trailer and make our caves look more naturalistic.
Key Features
Editor-level terrain edit brushes
Intuitive brush mechanics
Custom SDF Brush authoring
History-brush erasing
Terrain material painting
Y-slicing and Y-masking