Dungeon Architect for Unreal Engine 2.32 Help

PCG Framework Overview

In this tutorial, we'll have a look at the PCG framework and how it's used in the Electric Dreams sample

Pcg 01 c476df127f68bad541d87afc4f459bd4612f4ad5

Install

Download and Install the Electric Dreams sample from the marketplace

Boost your framerate with DLSS plugin [Optional]

This is a resource intensive sample. If you have an RTX card, you can boost your framerate by 2x or even 4x using DLSS and FrameGen. The NVIDIA DLSS plugin is currently unavailable for 5.3, however, I have instructions on setting this up for 5.3.

If the DLSS plugin is still unavialable for 5.3 while you're reading this, follow these instructions to install DLSS in 5.3

Setup

Load up the editor and create a new open world scene

image|536x450

Forest PCG Graph

Navigate to Content/PCG/Graphs/Forest. There's you'll find a PCG Graph asset PCGDemo_Forest. Drag-Drop that on to the scene

image|469x500

When you drag-drop a PCG graph asset on to the scene ,the editor would spawn a PCG Volume and set this asset in that volume. Then it run this graph inside the volume and we get a nice forest

image|690x374

Select the PCG volume and increase the bounds of the volume to create a larger forest

image|522x380
image|690x274, 100%
image|690x291

Select the PCG volume actor and click Cleanup to remove all spawned meshes. This is important if you are iterating and need to a clean rebuild. Click Generate to rerun the PCG graph and recreate the forest

image|690x402

Ditch PCG Blueprint

Cleanup the Forest PCG volume so the scene is empty.

Drag-drop the ditch blueprint PCGDemo_DitchBP on to the scene. You don't see much

image|458x500

This is a blueprint with a spline component. The ditch assets are spawned along the spline and this logic is invoked from within the blueprint. Select the dropped-in actor and hit Clean Regen

image|690x387
image|690x451

Regen / Cleanup

Notice that we don't have any buttons to destroy this from the scene, only the Clean Reg button (i.e. clean+build).

Lets add a cleanup button. Open up the blueprint PCGDemo_DitchBP

You'll notice that these 3 buttons are just blueprint functions with their Call In Editor flag checked

image|690x454

Duplicate the CleanReg function and name it Cleanup

image|441x380

Open up the newly created Cleanup function. We just want Cleanup here and no Generate. So get rid of Generate. Also make sure Call In Editor is checked. It should look like this.

image|690x295

Compile and save, switch back to the level editor, select the ditch blueprint actor and you should see a button to cleanup

image|276x111

Ditch Spline

The ditch blueprint has a spline. Select the actor in the level editor and select the Spline component

image|690x367

If you don't see the spline after selecting the spline component, make sure you're not in Game Mode (press the G key in the viewport to toggle game mode)

You can add / remove points and perform a clean regen

image|690x440

You might want to Cleanup before working on the spline

Once done, click Clean Reg

image|420x463
image|690x439

Select the Forest PCG volume and click Generate. You'll notice the forest doesn't generate inside the ditch spline

image|690x394

Ground Material

Select your Landscape and assign the landscape auto material that comes along with the sample

image|379x134
image|690x317
image|690x337
image|690x374

Ground PCG Graph

The sample comes with a PCG graph for decorating open spaces.

Drag drop PCGDemo_GroundBP anywhere on the scene

image|690x378
image|690x374
image|690x374
image|690x417

Extending the PCG Graphs

Fix Ground PCG Graph

Select the Forest volume and perform a Cleanup

image|506x500

Select the Ground bluerpint and perform a Cleanup

image|690x463

Then drop in another PCGDemo_DitchBP blueprint and hit Clean Regen

Your scene should look something like this:

image|690x432

Now select the PCGDemo_GroundBP blueprint and hit Generate

image|690x461

You'll notice that the ground was built only on the first spline. Epic has designed the Ground PCG graph this way to pick the first spline in the scene and build it there. Lets change that so it picks up all the ditch splines in the scene

Open the Ground PCG graph asset (not the blueprint)

image|650x333
image|690x239
image|690x193

Select the node that searches for the ditch blueprint and enable the flag Select Multiple

Save the blueprint, come back to the level editor, select the Ground PCG blueprint and regenerate

image|690x426

Fix Forest PCG Graph

The forest PCG graph has a similar issue. Select the forest volume and hit Generate

image|690x387

The forest doesn't generate over the first ditch spline, however it ignores the other splines

Open up the forest PCG graph: Content/PCG/Graphs/Forest/PCGDemo_Forest

image|690x340
image|690x341

Select the node that searches for the ditch blueprint and enable the Select Multiple flag

image|690x217
image|690x400

The forest should grow inside every ditch spline placed in the scene

Landscape Modifications

Modify the landscape and the PCG should automatically regnerate around it

image|690x358
image|690x458
image|690x458

Drop in PCGDemo_ForestCliffs and reset the location and set the scale to (200, 200, 10) so it covers a large area. This should add trees around the cliff area

image|690x334
image|690x379
image|690x331

Exclude PCG Generation around certain areas

Avoid PCG generation around certain objects. I've placed an asset here and I don't want the foliage, rocks and trees generated by the forest PCG graph

image|690x389

We'll update the forest PCG graph so it removes points within a volume (that we place around the house) so the forest doesn't grow there

image|690x369
image|690x322

The developers from Epic have created a provision for excluding the generation around a certain volume in the ditch blueprint (Content/PCG/Graphs/Ditch/PCGDemo_Ditch)

Lets open that up and copy that node over to the forest blueprint

PCGDemo_Ditch.uasset

image|690x355

Open up the forest pcg graph (Content/PCG/Graphs/Forest/PCGDemo_Forest)

image|690x332
image|690x278

Paste the node (that you copied from the ditch pcg graph) over here and link it to the Merge node as shown below:

image|690x367

This will remove all PCG points from the scene that are contained with PCG Volumes tagged with PCG_EXCLUDE. Save the graph

Now all you have to do is drop in a PCGVolume, navigate to the Tags section and add PCG_EXCLUDE

image|295x213

Select the volume you just created, and search for Tag in the details panel. Add a tag named PCG_EXCLUDE

image|510x500

Now move / rotate / scale your volume and the forest would not be generated inside this volume. I've wrapped the volume around the building. Feel free to make copies of this volume and reuse it elsewhere

image|690x427

Select the forest blueprint:

  • Click Cleanup to remove the forest

  • Click Generate

image|690x367
Last modified: 14 September 2024