PCG for Complex Level Design and Lumen for Real-time Lighting in Unreal Engine 5

Procedural Content Generation (PCG) framework is an amazing tool within Unreal which can be used in many different ways, from foliage, biome design to world building and more. It uses an algorithm to scatter points on landscape or any meshes and use the points data to place other assets/blueprint actors on top of it. So creating large scale forest and environments procedurally in Unreal has become very interesting and this will only get better and better with time.

 I wanted to test the PCG workflow and look into the possibility of creating complicated levels which otherwise would be very time consuming and tricky to create. When I came across PCG, I thought what if we can use it to create a large scale treasure vault like what Uncle Scrooge have in Duck Tales or something similar to the Smaug's Treasure from the Hobbit movie. 

The Result

 
(Treasure Level using PCG)
 
It is very interesting that how PCG can help us creating such complex level and keep most of the workflow non-destructive. Let us see how it came to life.
 
The Process
 
 At first, I created a landscape and took an chest asset to give some context to focus and to understand the scale. Then I created the PCG graph for the gold coins using the landscape data to sample the points onto the surface using a 'Surface Sampler' and transform them with 'Transform Points' to give some randomization. We can also make use of 'Bounds Modifier' to control the bounds of the points assets. Then a 'Static Mesh Spawner' is used to spawn a custom asset(gold coin) in place of if the point data. 

(Scattering and Mesh Spawning using PCG)

PCG Graph

(PCG Graph)

Once the base setup was done, now it was time to make it a proper level by designing it with the other set dressing elements like the cave rocks, treasure chests, etc. I used Megascan for the rocks and for the chest asset some Megascan materials were used to get the look & feel. 

The open chest asset needed to be filled with gold coins, so I used the scriptable tool option to create a physics based asset scattering tool and filled the chest with gold coins at runtime. Then those gold coin assets were converted into ISM (InstancedStaticMeshe) in a blueprint. 

[Pro Tip: If you want to tweak assets, make use of the Unreal modeling tools instead of going to DCC. This can save a lot of time if you want some quick changes to be done to your models. ]

(Chest asset variants)
 

 Combining the cave layout design with the PCG gold coins, the level composition started to come alive. To make the level and the area around the chest look more natural and interesting, I used the same Physics based scattering tool to scatter some gold coins and jewels around the chest area and across the level. Then the level was randomly populated with additional assets to make it feel more natural.

(Cave detail layout with scattered gold coins and jewels)

Lighting with Lumen

The lighting was another key part of the level's look & feel. I wanted to test Lumen and how it can help to get the visual fidelity of the whole level which I was targeting. I used the empty space between the cave rocks to be the main light source and using a SkyLight and RecLight also helps illuminating the whole scene. The Exponential Height Fog with Volumetric Fog enabled, further enhanced the mood of the scene.

(Lumen Lighting+Volumetric Fog) 

Lumen GI and Lumen Reflections were used in the Post Process Volume with the following settings.

(Lumen GI & Reflection settings)

[Pro Tip: Using the 4 spheres, as shown below, which resembles white, grey, black and metallic shader values, are a nice to way to determine the balance in lighting for any scene. Working with PBR workflow, it is very important to have a consistency in the shading and how lights, other post effects are reacting to it. So this helps to keep a check for all those.]

(4 Sphere actors with various shaders)

Color Correction

Some color corrections, exposure and bloom adjustments were also done in the Post Process. This is purely based on a personal taste and the look & feel you want to go for.

(Detail Lighting with Final Color Correction)

Final Thoughts

I am quiet happy with the output, specially that this type of complex level can now be done procedurally within the engine and in a short span of time. Another cool thing is that this runs at around 40 to 45fps in editor on my rtx 2060. So with some tweaks and optimizations, this can easily run at 60fps which is great for games.

PCG is just great and I have barely scratched the surface. It is very promising in so many ways and procedural-ism has got a different meaning in Unreal. I would like to explore more of it in future and see how it can be utilized in various other ways. 

Lumen is spectacular and it has been integrated beautifully in the Engine for look-dev and lighting that everyone need to use it. I have read and heard that it even works better with Nanite meshes, so that is something which would be interesting to explore.

 
Cheers!

 
 
 
 
 



Comments

Popular posts from this blog

Rigid Body Fx For Games Using Houdini & Unreal Engine (Part 1)

Volumetric Effects Emerging in Real-time