ProcGen Graph Placement Output
The Placement Output node is at the heart of the procedural placement system. This node specifies which prefabs to spawn, what density to use, how to position each object and how to add variety.
A ProcGen graph can already work, even if it contains just a single of these nodes. However, you can add as many of these nodes as you like. Every placement node represents a different type of object, with different conditions under which they are spawned.
For example one node would be used to spawn stones on rocky surfaces, another node spawns bushes on grassy surfaces, a third spawns trees and so on. Every type of object has a footprint, meaning an certain size of area in which only one of them will be placed. The larger the footprint, the more sparse these objects are spawned. The node itself can already filter whether to place an object, at all, by inspecting the surface. This way vegetation isn't planted on concrete or water.
More elaborate filtering can be achieved with modifier nodes. For example an image can represent where exactly what type of object should appear.
Node Properties
Name
: A custom display name that is shown in the node's title bar. This has no function other than to make it easier to find in the graph.Objects
: A list of prefabs. When an object gets placed, which one to use is either chosen through theObjectIndex
pin, or randomly, if the pin is not connected.Footprint
: The radius (in meters) of the circle in which a single object gets placed. Increase the footprint to make object placement more sparse, decrease it to make it more dense.MinOffset
,MaxOffset
: How much the position of the placed object may randomly deviate from the center position. If this is large enough and the footprint is too small, neighboring objects may end up overlapping. It is common to setMinOffset
to-MaxOffset
. If an object may only move upwards, but not downwards, keepMinOffset.z
at0
and only setMaxOffset.z
to a positive value.YawRotationSnap
: All placed objects are rotated randomly along the up axis. If this is non-zero, the used rotation angles are always a multiple of it.AlignToNormal
: How much to blend the placed object up direction towards the underlying surface's slope. If this is zero, the placed object always stands upright, regardless of the slope. If it is set to one, the placed object will fully follow the slope of the terrain. Anything in between, the object bends more or less towards the slope.MinScale
,MaxScale
: How large the placed object is at least (MinScale
) and at most (MaxScale
). The final scale is a blend between min and max, so if both values are uniform (x = y = z), the object's scale is also always uniform.ColorGradient
: An optional color gradient from which a random color is chosen to set the mesh color (in fact aplMsgSetColor
is sent when the object is spawned, so this could also be used to implement other features). If theColorIndex
pin is connected, the incoming value in the [0;1] range is used instead to lookup the color from the gradient.CullDistance
: At what distance to start spawning this type of object. For large objects with a low density, this distance can be increased. Small objects with high density should use a small distance, to prevent performance issues.PlacementMode
: How to determine the location where to place objects.Raycast: In this mode a physics ray is cast downwards from the volume of the placement component. Using the
CollisionLayer
andSurface
as filters, the closest intersection point is used.Fixed: In this mode objects are always placed at the height of the placement component. No ray is cast, and no location is filtered out. This can be used for 2D games where no collision geometry exists. Custom filtering can still be achieved through image volumes and other modifiers.
CollisionLayer
: The collision layer to use whenPlacementMode
is set to Raycast. The collision layer decides which physical objects will be hit by the raycast and thus on which surfaces objects may get spawned at all. Note that in Raycast mode objects can only be placed, if a collision meshes exist in the scene at all (greyboxes and heightfields set these up automatically).Surface
: An optional surface that's used to filter object placement. Objects will only be placed on surfaces of this type (or derived). This is used to only plant certain vegetation on each type of ground.Filtering by surface can also be very useful to prevent procedural objects from getting spawned on top or inside of other procedural objects. The left image shows gras being placed on top of the procedurally placed rocks, in the right image a surface filter prevents this from happening:
Input Pins
Density
: A value in [0;1] range that determines how likely it is that an object gets spawned. A lower density means that fewer objects get spawned. If this pin is not connected, a default density of1
is assumed. Connect this pin to a Perlin noise node or an modifier node to vary density by location. The image below shows varying density using Perlin noise.Scale
: A value in [0;1] range to blend betweenMinScale
andMaxScale
. This can be used to scale objects up or down by location or other environmental influences. If this pin is not connected, every object uses a random scale factor. The image below shows varying scale using Perlin noise.ColorIndex
: If aColorGradient
has been set, connecting this pin allows you to decide which color to use for an object. The value is in [0;1] range, with0
selecting the left-most color from the gradient and1
the right-most color. The image below shows varying color tint using Perlin noise.ObjectIndex
: If more than one prefab is added to the object list, this pin can be used to select a specific one. The value is in normalized [0;1] range, so if two objects are in the list, the first one is selected by any value between0
and0.5
and the second by values between0.5
and1
. The image below shows how varying prefabs are picked by Perlin noise.