Magivoid Devlog #5.2 - Engine upgrade and PCG
Tags: gamedev, devlog
Published: 2023-06-23 02:36:48

---
title: Magivoid Devlog #5.2 - Engine upgrade and PCG
published: true
date: 2023-06-21 00:00:00 UTC
tags: gamedev, devlog
canonical_url: https://tinygame.dev/posts/Magivoid-Devlog-5/
---


## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c3z5zhswxgfgvfoqykgm.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jh1c1zhezlcpacla5hzi.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5mdoly9u31svratn3mra.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2y15av7n23y8dw5qpb94.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgtwfg6z2dxnzgz63jlu.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5128dpftq2spu49srdy8.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78matw89b7kyvsy4zrsq.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmxpddb7dqn3jf9ptvcc.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xc2f37oj1g6qlrazdp3j.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aimqxd8kh6dzyzz7x5wj.png)


## 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 here: [https://tinyletter.com/tinygamedev](https://tinyletter.com/tinygamedev)


## Links

* [UE 5.2 PCG Tools](https://docs.unrealengine.com/5.2/en-US/procedural-content-generation-overview/)
* [Pathways & Roads using RVTs](https://www.youtube.com/watch?v=momc4h5J19Y)
* [Unreal PCG Tutorial](https://www.youtube.com/playlist?list=PLA03OHAaHgYpo0enf8p-2oEpja3grLOKZ)