083 - Editable Terrain Layers

September 06, 2020

This week I started working on creating a terrain displacement sculpting tool for the editor.

I started off by reading about how other engines have approached terrain sculpting, and in the process I came across the idea of having a layered terrain editing system.

In a layered editing system you can have any number of editable layers per terrain chunk, each having their own displacement map.

The final map for the chunk is generated by blending all of its layers.

This approach is an improvement over a non-layered editing system in a number of ways, the main advantage being that a layered editing system allows you to iterate on your terrain's details without ruining areas that you are already satisfied with.

You can create a new layer when you want to experiment with adding detail. If things don't work out you can delete the layer, all without needing to modify and potentially ruin the other layers that you are already happy with.

Even though the advantages were clear, having a layered terrain editor was not an immediate need of mine.

Despite this, I decided that the difference in the architecture of a layered system vs. a non-layered system would be significant enough that it would be much easier to add in from the beginning as opposed to in the future.

So I spent the bulk of this week re-factoring the editor's terrain data structures to cater to an editable-layer system.

Terrain Edit Layers

In 080 I implemented saving and loading chunked terrain data too and from disk.

These in memory and disk representations did not at all account for layers, so I re-worked them this week over the course of a few days.

I ended up encapsulating the concept of edit layers into a TerrainEditLayers struct, which in turn uses other layer-friendly data structures.

pub struct TerrainEditLayers {
    child_to_parent: HashMap<TerrainEditLayerOrGroupId, TerrainEditLayerGroupId>,
    parent_to_children: HashMap<TerrainEditLayerGroupId, Vec<TerrainEditLayerOrGroupId>>,
    layers_meta: HashMap<TerrainEditLayerId, TerrainEditLayerMeta>,
    groups_meta: HashMap<TerrainEditLayerGroupId, TerrainEditLayerGroupMeta>,
    layer_chunks: HashMap<TerrainEditLayerChunkId, TerrainEditLayerChunk>,
    root_group_id: TerrainEditLayerGroupId,

I designed the disk representation that the in memory representation gets serialized into to be resistant to merge conflicts.

Data is split across files in such a way that if two different branches are working on two different areas of the terrain they won't have any merge conflicts.

This was not necessary for me at this time since I don't plan to work on terrain across branches anytime soon, but I still implemented it because it was much easier done now vs. later.

Other Notes / Progress

The work on the scenery placement tool and now the work-in-progress terrain sculpting tool has begun to set a technical foundation that future editor tooling will be able to build upon.

In a week or two I will start working on the terrain material painting tool, which I expect will lean heavily on the code that I'm currently putting into place for the terrain sculpting tool.

This tooling journey has been fun. I get excited about writing tools to simplify arduous processes.

I'll keep pushing and get these tools done. Then I can get back to working on adding game play into Akigi.

It's taken me four weeks to get one and a half of the tools that I want to add into place, so at this point I'm estimating another four weeks before I return to working on game play features.

There will be more work to do on these tools going forwards after I finish this first batch of three, but that can happen in smaller pieces over time on an as needed basis.


Our finances for August 2020 were:

itemcost / earning
revenue+ $4.99
aws- $269.23
adobe substance- $19.90
GitHub- $9.00
adobe photoshop- $10.65
adobe illustrator- $22.38
Datadog- $8.12
total- $334.29

I need to look into what's going into the AWS bill and see if there's anything that I can remove. Would be nice to get it under $200 per month.

Next Week

Now that I can save and load terrain editable-layer data I'll be turning my attention towards implementing the front-end for terrain sculpting.

This will include things such as being able to change into a terrain sculpting mode, being able to click and drag to sculpt terrain, as well as a list of other supporting implementations.

In the next journal entry I'll be sharing a video of my progress on the sculpting tool.

Cya next time!