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.
- First place the
Biomes PCG World Settings
actor on the level. This will communicate to thePCG
integration subsystem that you want to create PCG data assets from biomes. You can place the actor by going into theAll Classes
drop-down and typingBiomes PCG
- 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. - If you want to spawn species from PCG you need to disable spawning in Errant Biomes
- 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.
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.
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.
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.
Nodes
Errant Biomes Mask
You can access masks from species and sub-biomes by using the Errant Biomes Mask
node.
Each of the points passed into this node will have its Density
value changed to the value from the mask.
You can easily combine that with the built-in Density Filter
node to remove points that have low mask values.
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
.
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.
- Add
PCG Volume
on the level. - Use the "Simple Forest" graph.
- Follow setup steps.
- Setup Errant Biomes in the level
- Create a sub-biome and set up its mask. For example by adding the Noise node to the material and exposing the noise parameters.
- In the
PCG
graph addErrant Biomes Mask
node after the node that creates points over the landscape. - Set mask type to
Sub Biome
and choose sub-biome asset. - Add the
Density Filter
node after theErrant 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.