- Documentation
- Pullsar Noise Lab
- PCG Example
PCG Example
This page describes one example that was run and checked in Unreal Engine 5.8.4: a PCG graph that reads one region’s mask from a Noise Lab region interchange bundle, keeps the points inside that region, and filters them by the region’s purpose or tag from the CSV.
Noise Lab does not import anything into Unreal for you. There is no plugin, no automatic import of the sidecar or CSV, and no one-click PCG setup. You import the files and build the graph yourself.
What was verified
Section titled “What was verified”The example was verified in a scripted run on a throwaway test project, in Unreal Engine 5.8.4 (build 5.8.4-58902052+++UE5+Release-5.8). An unattended editor ran a script that imported the files and built and ran the PCG graphs. The editor’s import dialogs, details panel and PCG graph editor were not used. See What was not tested.
The input was a package with the interchange bundle turned on, made from the default terrain (Rolling Hills, 1009 × 1009, 1008 m wide). It had four regions, set up in a recipe with these ids. Regions you draw in the app get ids such as r1.
| Region id | Shape | Purpose and tag | Note |
|---|---|---|---|
camp |
Circle | Build site, camp |
|
1001 |
Rectangle | Exclusion, no_foliage |
Its blend overlaps the blend of camp |
x1 |
Spline | Route, path |
|
r9 |
Rectangle, switched off | Vegetation | In the CSV only, with no mask |
| Check | Result |
|---|---|
| Landscape | The package’s .r16 was imported as a new Landscape with the manifest’s scale (100, 100, 100), location (0, 0, 0), 63 quads per section and 2 × 2 sections. All 64 components matched: every stored and collision height equaled the .r16, and the actor sat at (−50400, −50400, 0) cm. |
| Mask textures | Each mask PNG became its own texture asset named like the file, including ..._region_1001_mask. Unreal did not group it with others as a UDIM texture. |
| Alignment | PCG’s Sample Texture read the mask at 1,368 positions on and between landscape vertices, in cores, blends, an overlap and outside every mask. The largest difference from the value expected from the PNG was about 0.00002 of one 8-bit level, and the mean about 0.000001. The pre-set limit was half a level. |
| Wrong mappings | A flipped Y axis, a transposed mask and shifts of half a vertex or one vertex each failed that limit, so the test could tell a misaligned mask from an aligned one. |
| DataTable | Unreal imported the CSV with no problems into 4 rows named camp, 1001, x1 and r9. Every field equaled its CSV cell, Enabled was read as true or false, and empty cells became empty strings. A copy with CRLF line endings gave the same rows. |
The semantic graphs then used the mask and the DataTable together. The counts below depend on the graph’s settings (a Surface Sampler at 0.04 points per square meter, and a Density Filter from 0.5 to 1), so your counts will differ.
| Graph input | Filter | Points kept |
|---|---|---|
Mask 1001, RegionId 1001 |
Tags contains |no_foliage| |
388 |
Mask 1001, RegionId 1001 |
Tags contains |camp| |
0 |
Mask camp, RegionId camp |
Purpose equals build_site |
379 |
Every kept point lay where its mask was at least 0.5 and carried the purpose, tags and Enabled value of its region. The points kept for the 1001 mask were almost zero in the camp mask, and the other way round. The camp points were centered on the circle’s center within 0.2 m.
Independent smoke test
Section titled “Independent smoke test”A second, separate check was run in another Unreal Engine 5.8.4 project (5.8.4-58902052+++UE5+Release-5.8), in an interactive editor rather than an unattended one. It corroborates that mask-driven PCG placement works. It does not test filtering by purpose or tag.
The input was a package exported with the interchange bundle, made from the default terrain (Rolling Hills, seed 1337, 1009 × 1009) with regions. The Landscape was imported through the Landscape panel (New, Import from File) with the manifest’s scale (100, 100, 100), 63 quads per section and 2 × 2 sections, which gave 64 components. The editor’s own Python scripts ran the other steps, and the panel was operated through an automation toolset, not by hand.
| Check | Result |
|---|---|
| Landscape | 1009 resolution, 64 components, and the actor at (−50400, −50400, 0) cm. Ten line traces at vertex positions were within 0.06 cm of the height the .r16 gives |
| Mask texture | The region r1 mask imported with Unreal’s default settings (sRGB on, a UI compression), which are wrong for this use. It was changed to the required texture settings and saved |
| PCG graph | Get Landscape Data, Surface Sampler (0.04 points per square meter), Sample Texture with the mask from Get Texture Data, Density Filter from 0.5 to 1, and a Static Mesh Spawner with the engine’s cube |
| Placement | 576 cubes, all inside the r1 mask. The bilinear mask value at every cube was at least 0.5 (minimum 0.502), and all were within the region’s radius plus its blend. 365 lay in the core and 211 in the blend |
| Exact set | The cubes were exactly the sampler’s lattice points where the mask is at least 0.5: 576 expected, 576 placed, none missing, none extra. The region is off the map’s diagonal, so a flipped, transposed or shifted mask would have selected different points |
| Persistence | The count stayed 576 and the exact-set check passed after a save and reopen of the level, and after a forced regeneration |
The PNG was decoded independently, outside Unreal, to compute the expected points.
This confirms mask-driven placement only. The graph did not filter on purpose or tags, and no DataTable was created. The CSV row for r1 was checked against the sidecar by reading the files. The placement used the editor’s CPU texture path. Cooked and runtime builds, World Partition, a moved or rotated Landscape, other resolutions and other regions were not tested.
Required texture settings
Section titled “Required texture settings”| Setting | Unreal’s default import | Required |
|---|---|---|
| sRGB | On | Off |
| Mip Gen Settings | NoMipmaps | NoMipmaps |
| Compression Settings | UserInterface2D (the editor icon type) | VectorDisplacementmap (RGBA8) |
The file’s bytes are stored correctly either way. With sRGB on, PCG reads the texture through the GPU and applies the sRGB-to-linear conversion, so the sampled values differ from the PNG.
With these settings, every texel of the imported texture equaled the PNG byte, and PCG read the mip 0 data directly. Keeping the default import and turning on Force Editor Only CPU Sampling on Get Texture Data also gave exact values, but only in the editor.
- Export. Export a package with Region interchange turned on, and extract the ZIP.
- Landscape. In Landscape mode, choose New, then Import from File, and import the
.r16with the values from the Unreal import section. See Unreal Landscape Import. Note the actor’s locationLand its X scaleS. At 1009 vertices and scale 100,Lis (−50400, −50400, 0) andSis 100. - Masks. Import the
_region_<id>_mask.pngfiles, set the required texture settings on each, and save. - DataTable. Create a struct with String fields
RegionId,Purpose,TagsandMaskFileand a Boolean fieldEnabled. Import_interchange.csvas a DataTable with that struct. The CSV’sNamecolumn, which holds the region id, becomes the row name. - Volume. Place a PCG Volume that overlaps the Landscape.
- Graph. Build this chain:
- Get Landscape Data, then Surface Sampler.
- Get Texture Data with the mask as the texture, Use Absolute Transform on, Density Source Channel set to Red, Filter set to Bilinear and advanced tiling off. Set its location to
L + S × (N − 1) / 2in X and Y and its scale toS × N / 2in X and Y and 1 in Z, whereNis the resolution. At 1009 and scale 100 that is location (0, 0, 0) and scale (50450, 50450, 1). - Sample Texture in Planar From Texture Data mode with the density merge set to Set. It takes the points from the sampler and the base texture from Get Texture Data.
- Density Filter, for example from 0.5 to 1, to keep the points inside the region.
- Add Attribute named
RegionId, type String, with the region’s id as the value. - Load Data Table with the DataTable and Output Type set to Attribute Set, connected to the Match Data pin of Match And Set Attributes. In that node, turn Match Attributes on, set both attributes to
RegionId, and turn Keep Unmatched off. - Attribute Filter with Use Constant Threshold on, type String. For a tag, use target
Tags, operator Substring and value|no_foliage|. For a purpose, use targetPurpose, operator Equal and valuebuild_site. - Take the points from the Inside Filter pin.
- Check. Generate the graph on the volume and inspect the points, for example with debug display.
When you export again, replace the textures, the DataTable and the RegionId values in the graph together. A later export can reuse a deleted region’s id for a different region.
Requirements and pitfalls
Section titled “Requirements and pitfalls”- The PCG Volume must overlap the Landscape, because Get Landscape Data only returns Landscapes that overlap the component’s bounds.
- Match And Set Attributes needs Match Attributes on and Keep Unmatched off. Its defaults behave differently: with Match Attributes off it selects randomly, and with Keep Unmatched on it keeps unmatched points with default values. The defaults were not tested.
- Unreal’s Load Data Table node exposes only the struct’s fields, not the row name. That is why the CSV repeats the region id in the
RegionIdcolumn. - Tags are written as
|camp|no_foliage|, so a Substring filter on|tag|matches one whole tag. - A mask is sampled at the vertex positions of the Landscape. At a vertex, PCG returns that vertex’s byte. Between vertices it blends the neighbors, so a point near a vertex can differ from that vertex’s byte by several levels.
- Leaving Density Source Channel at its default, Alpha, is expected to give density 1 everywhere, because the texture’s alpha is 255. This was inferred from the engine sources and not run.
What was not tested
Section titled “What was not tested”These are not tested. Treat them as unknown, not as unsupported or as working.
- The editor UI path: the texture and CSV import dialogs, the details panel and building the graph in the PCG graph editor.
- Runtime generation and cooked builds. The exact route used here is editor-only. At runtime the same texture would be read through the GPU, which is expected to be exact for a texture with the required settings, but was not measured.
- Unreal Engine versions other than 5.8.4.
- World Partition, and partitioned or hierarchical PCG generation.
- Resolutions 505 and 2017. Only 1009 was run.
- A Landscape that is moved off the origin, rotated or scaled unevenly. Only a Landscape centered on the origin with scale 100 was run.
- Get Texture Data with Use Absolute Transform off.
- Static Mesh Spawner, other than in the independent smoke test above, which spawned the engine’s cube on a 5 m lattice. Any other use of the points beyond filtering them.
- Texture edges and addressing. All the test masks are 0 at their borders.