Skip to content

An overview of PCG in Unreal Engine 5.8.4+

PCG

General tips

Inspect data

Preview data in the PCG graph viewport

  • Add a Bounds Modifier
  • Set Settings > mode to Set
  • min (-50, -50, -50) max (50, 50, 50)
  • Inspect (A) This will show the points in the viewport

Transform PCG with actor transform

You probably want to move the PCG points with the actor transform

  • Add Get Actor Data
    • Data Retrieval Settings > Mode : Get Single Point
  • Add a Copy Points node
    • connect the output of the Get Actor Data to the Target input of the Copy Points node
  • Connect the output from the Load Alembic node to the Source input of the Copy Points node
  • Connect the Out output of the Cop Points node to the "rest of the graph"
  • Note!
    • If you do not want the seed to change when the actor is moved (like when you are using poisson sampling)
    • make sure to set the Settings > seed inheritance to source on the Copy points node

Add blueprint variable to control pcg graph

How to add a blueprint variable and use that in PCG

  • Open up the blueprint that holds our PDG graph.
    • Add a variable, lets call it "global_scale"
      • Set the type to float
      • Make it public
      • Set default value and slider min max (optionally value range)
    • Compile and save
  • Open up the PDG graph
    • Add a Get Actor Property node
      • Set the Settings > Property Name -> "global_scale"
      • Set the Settings > Output Attribute Name -> "global_scale"
    • Then you can use the Output and connect to whaterver you want to control

PCG spline mesh

How to setup a spline mesh in PCG

  • Add a blueprint and open it
    • Add a spline component
    • Add a PCG graph
    • Add a variable called "static_mesh"
      • Type: static mesh object reference
      • Make it public
    • Add a variable called "material"
      • Type: material instance object reference
      • Make it public
  • Open the PCG graph
    • Get the spline component from the blueprint
      • Add Get Spline Data node
    • Sample the spline and create a new spline
      • Add a Spline Sampler node
        • Conect the output from get spline data node to the spline input of the spline sampler
        • Set the Settings > Mode to Distance
        • Set the Settings > Distance Increment
          • This will we control later by calculating the mesh bounds
      • Add a Create Spline node
        • Connect the output of the spline sampler to the input
        • The reason we build a "spline again" is because the mesh will be stretched between the spline control points, and by diving the origimnal input spline we can make sure each segment is adjusted to the length of the input mesh
    • Get the "static_mesh" variable and set attribute
      • Add a Get Actor Property node
        • Set the Settings > Property Name to "static_mesh" (the same as in the BP)
        • This will get the "static_mesh" variable and will set the mesh
      • Add a Add Attribute node
        • Connect the Out from the Create Spline node to the In input of the Add Attributes node
        • Connect the Out from the Get Actor Property node to the Attributes input of the Add Attributes node
        • Set Settings > Input Source to "static_mesh"
        • Set Settings > Output Target to "static_mesh"
    • Get the "material" variable and set attribute
      • Add a Get Actor Property node
        • Set the Settings > Property Name to "material" (the same as in the BP)
        • This will get the "material" variable and will set the mesh
      • Add a Add Attribute node
        • Connect the Out from the "static_mesh" Add Attribute node to the In input of the Add Attributes node
        • Connect the Out from the Get Actor Property node to the Attributes input of the Add Attributes node
        • Set Settings > Input Source to "material"
        • Set Settings > Output Target to "material"
    • Spawn the spline mesh
      • warning: Failed to attach the component, check logs

        • If you get this warning you can resolve it by:
        • Setting the default scene root of the containing blueprints mobility to Static
        • You could also set the spline component mobility to static
        • Seems like the mobility needs to match
      • ToDO
        • set the mesh and material

cvar

  • if meshes dissapear when you zoom out
    • r.RayTracing.Geometry.InstancedStaticMeshes.Culling 0