5 min read

Magivoid Devlog #5.2 - Engine upgrade and PCG

Magivoid Devlog #5.2 - Engine upgrade and PCG

Engine Upgrade

We’ve been a bit quiet lately but boy have we been busy. There’s tons of new content in the game. Too much for one post, but I’m getting ahead of myself here. Let’s start with the biggest change.

Since our last devlog Unreal Engine 5.2 has been officially released and we took this chance to update the project. The more exciting addition in this release was the new procedural content generation tools. This brings Houdini-style graph-based tools for procedurally building out your maps in the Unreal Editor. Very exciting for us, since you may remember our map mostly looking like this:

What our map used to look like

With a bit of PCG magic, and the awesome work done by Epic on these tools, our map now looks like this:

What our map looks like now

Let’s go over how we got here.

Procedural content generation in UE5

The trick to getting good results with these PCG tools is to layer multiple ideas on top of each other. Similar in concept to how you would layer multiple octaves of Perlin noise to get a richer result, only here the operations are much more freeform as you’re working with a graph.

Our setup is pretty simple and starts with a looped spline that defines the area where we want points to be generated. We apply density noise and a filter to create a more sparse distribution of points and use this first pass to pick locations where we place our largest trees. This forest will serve as the core of our map.

We have at our disposal graph nodes for various transform operations that slightly rotate and scale the meshes to add a subtle variation in how each tree is placed.

Nice forest, but too dense

This may look ok, but for our needs it’s a bit too dense. We’ll need a bit of open space as well as freedom to move and see through the trees. It’s an easy fix with another layer of density noise and filter to get rid of random points.

Nice forest, not too dense

The next step is to fill the gaps between the trees. We do this with various bushes and shrubs by generating grids of points around a random selection of spawn points that are slightly biased towards being closer to the center of the map. After applying randomization to location, rotation, and scale for each point in the grids, we get these nice clusters of bushes that are more concentrated the closer they get to the core of the forest.

Clusters of spawn points for bushes and flowers

Once we filter these points and pick only a dozen or so to spawn meshes at, we end up with a nice distribution of larger vegetation on the map.

Resulting bushes and flowers

We do another pass of filtering the point grids around the large trees and for points closer to the trees we spawn various mushrooms. The idea here is that mushrooms grow closer to large trees where presumably they get more shade.

A bunch of shrooms under trees

We have the ability to detect the distance from a potential spawn point to the edge of our PCG spawn area, defined by our looped spline, which can tell us if a point is closer to the center or the edge of the forest. We use this data to spawn various rocks all over the map, but mostly at the periphery of the forest. We don’t want a complete absence of rocks at the core, but ideally we see more of them closer to the edge of the map and next to the mountains.

A bunch of rocks not all close to trees

Up next we have a river that introduces a bit of blue in this vast sea of green. The river is built with a landscape spline that gently carves into the terrain and a spline mesh for the water plane. Here the PCG tools are of great help with their support for sampling points along a spline. We use the spline sampling node to detect where our river sits in the map and use this data for two operations. First, we cull any of the points we use for trees and bushes that directly intersect the river. Second, we generate a new set of points along the sides of the river and spawn a new type of vegetation like ferns as well as some additional rocks.

Our pretty river that may also contain some rocks

In addition to the river, we used splines to set up a few paths through the forest to break up the monotony of seeing only trees. The road spline is a regular actor with a simple spline mesh that projects itself onto the terrain by writing to a Runtime Virtual Texture. This allows us to paint the path with a different dirt material, remove grass or change its color, and affect the PCG spawn point distribution by culling trees and vegetation automatically if they intersect the path.

It wouldn't be a forest without a path going through it

Next up

In the name of keeping each devlog relatively short, we stop here having mentioned some of the world building we’ve done since our last post. There’s a significant amount of new content like monsters and weapons playing really well. I’d love to share more about them soon. Hopefully I will have some time for writing in between sprints of development work.

We’ve also launched a newsletter for those of you who would like a more intimate view of the development and progress on Magivoid. Don’t expect many emails though, we send them out rarely, but promise they will have worthwhile content!

Subscribe below!