Skip to main content

PCG

Integration

Errant Biomes is integrated with Unreal's PCG framework (Procedural Content Generation), enabling you to access Errant Biomes-generated data in PCG. This integration offers increased granularity of control without compromising the usability or user-friendliness of Errant Biomes.

You can take advantage of this integration in two ways:

  • Utilize Errant Biomes as your main system, but turn off spawning for certain Species. In this setup, Errant Biomes generates spawn points for these Species, which are then passed to PCG for additional processing and spawning.
  • Use PCG on its own, while also incorporating Errant Biome masks and sub-biomes as supplementary inputs.

To determine the optimal integration approach, let's review the benefits of each system (as of 05.2023):

Errant Biomes:

  • Provides high performance and stability for large worlds (over 8x8K) containing many complex species.
  • Supports tiled generation and regenerating a smaller fragment of the map.
  • Provides a useful organization of assets into biomes, sub-biomes, and species.
  • Asset organization and granularity are tailored to promote efficient collaboration in larger teams.
  • Offers an intuitive, priority-based system for removing overlapping objects.
  • Supports spawning dense objects at runtime (e.g., grass, decals, pebbles) around the camera, based on compressed spawn points. This doesn't require including "editor" assets in the game.
  • Provides access and tools for hand-painted masks, volumes, and biome masks generated by Errant Landscape brushes.
  • Enables the alteration of the landscape beneath the spawned species/sub-biomes.
  • Offers efficient visualization and debugging tools.

PCG:

  • Allows for custom logic on a per-point basis.
  • Enables extra spatial tests and raycasts.
  • Supports spawning on top of meshes.
  • Enables removal of objects based on their bounding boxes.
  • Supports runtime generation (in-game), but may require including "editor" assets in the packaged game.

Setup

Biomes PCG module creates data assets that can be used in PCG graphs, even at runtime.

tip

This setup is needed only for access to Species/Sub-Biomes masks and Species transforms. For access to hand-painted/Errant Landscape/Errant Paths masks this setup is not necessery and it's enough to just use the Errant Biomes Mask node.

  1. First place the Biomes PCG World Settings actor on the level. This will communicate to the PCG integration subsystem that you want to create PCG data assets from biomes. You can place the actor by going into the All Classes drop-down and typing Biomes PCG
  2. In the spawned Biomes PCG World Settings you can define what Biomes data will be needed in your PCG graphs. Biomes Data Limit allows you to create a list of Biomes assets for which the PCG data will be created.
  3. If you want to spawn species from PCG you need to disable spawning in Errant Biomes
  4. Generate biomes in the Errant Biomes again, after the setup to create PCG data assets. You might need to clear the Errant Biomes cache to force regeneration.
danger

Only offline spawned Species can be used with PCG currently (as of Errant Biomes 1.5). Species that use Runtime Spawning in Errant Biomes won't generate any spawn points in PCG.

Reach out to us if such support is crucial for your project.

For offline generated Species, PCG can spawn them both offline and at runtime.

Disabling spawning in Errant Biomes

If you want to fully control spawning from PCG you'll need to disable spawning in Errant Biomes, otherwise you'll end up with duplicate instances.

You can do that by going into Errant Biomes Mode, Setup, Advanced and changing Elements to generate. You can disable Spawn so only masks and transforms are generated.

Disabling Errant Biomes Spawning

You can also disable spawning for single species by setting Spawn Instances property to false. That species will generate masks and points for PCG, but Errant Biomes will skip spawning.

Species Spawn Instances Property Image

Limiting what is sent to PCG

In order to integrate with PCG this module creates new data assets that are usually not needed if you're only using Errant Biomes. If you don't want to use PCG for all your species you can limit PCG Biomes Data creation in the Biomes PCG World Settings actor properties. There you can control what assets will have their PCG data created by adding them to an Allowlist or to a Blocklist.

PCG Biomes Data Limit Image

Nodes

Errant Biomes Mask

You can access masks from species, sub-biomes, hand-painted, Errant Landscape, and Errant Paths by using the Errant Biomes Mask node. Each point passed into this node will have its Density value changed to the value from the mask.

To access data from species and sub-biomes you need to perform steps in the setup section as those masks are not normally stored on disk after generation. All the other, disk-saved, masks are available without those setup steps.

You can easily combine node output with the built-in Density Filter node to remove points that have low mask values.

PCG Biomes Mask Nodes Image

Errant Biomes Species Points

You can access generated transform points from species by using the Errant Biomes Species Points node.

Each of the points will not only contain transforms for that species but also assets that should be spawned. Assets to spawn will be stored as a SpeciesAssetPath attribute. You can use that with the built-in StaticMeshSpawner node to spawn assets that you've selected in the Biomes Species asset. In the StaticMeshSpawner use Mesh Selector Type: PCGMeshSelectorByAttribute and in the Attribute Name property input: SpeciesAssetPath.

PCG Species Points Nodes Image

Examples

Modifying Simple Forest example for use with Sub-Biome mask

In this example, we'll add a Sub-Biome mask to the PCG "Simple Forest" example graph.

  1. Add PCG Volume on the level.
  2. Use the "Simple Forest" graph.
  3. Follow setup steps.
  4. Setup Errant Biomes in the level
  5. Create a sub-biome and set up its mask. For example by adding the Noise node to the material and exposing the noise parameters.
  6. In the PCG graph add Errant Biomes Mask node after the node that creates points over the landscape.
  7. Set mask type to Sub Biome and choose sub-biome asset.
  8. Add the Density Filter node after the Errant Biomes Mask node to control the removal of points.

Cooking

Runtime data specific to PCG generated from Biomes is stored within the ErrantBiomesPCGData directory, which is located adjacent to the map file. It is essential to include this directory in your cook paths to ensure data availability and functionality in game.