pcg nodes

6 node types in the pcg category.

attribute_from_map#

aliases: attribfrommap attrib_from_image texture_to_attrib attrib_from_map attribute_from_image texture_sample

Sample a PNG image (8/16-bit grey or RGB(A)) into a point attribute by uv or by a planar projection (xz ground maps, xy/yz walls): density maps, masks, colour.

Houdini: Attribute from Map; Unreal PCG: Get Texture Data + Sample Texture. projection uv reads the uv attribute (point or vertex; GPU convention: pixel centres at (i + 0.5) / width, v = 0 at the bottom of the image unless flip_v). Planar projections map the image onto a size × size rectangle around center with the first and last pixels on its edges (the layout heightfield_from_image and export png16/mask_png use): xz = top view, column along +X, row 0 at min Z; xy = facing +Z, column along +X, row 0 at max Y; yz = facing +X, column along −Z, row 0 at max Y. channel luminance (Rec. 709), r, g, b, a or rgb (a vector); remap maps black..white to remap[0]..remap[1]. Bilinear or nearest filtering; wrap repeat, clamp or mirror outside the image. class vertex writes per vertex (uv seams stay sharp); point averages a point's vertices when uv is a vertex attribute. The file is re-read when it changes.

Inputs

#namedescription
0geopoints or mesh

Parameters

nametypedefaultrangedescription
pathpath""PNG file or URL; a relative path reads from the package folder (nearest .topo file), else the graph's folder
aliases: file filename map texture image
namestring""output attribute ("" = Cd for channel rgb, else mask)
aliases: attrib attribute output
channelenum"luminance"which channel (rgb writes a vector)
options: luminance r g b a rgb
projectionenum"uv"uv attribute or a planar projection (xz = top view)
options: uv xz xy yz
aliases: mapping
uv_attribstring"uv"projection uv: the uv attribute (vertex or point)
sizevec2[10,10]planar: extent of the image in metres (columns, rows)
centervec3[0,0,0]planar: centre of the image rectangle
aliases: t translate origin
remapvec2[0,1]output value for black and for white
aliases: range
wrapenum"clamp"outside the image: clamp to the edge, tile, or mirror
options: clamp repeat mirror
filterenum"bilinear"pixel interpolation
options: bilinear nearest
aliases: interpolation
flip_vboolfalseflip the image vertically
classenum"point"write a point attribute or a vertex attribute
options: point vertex
groupgroup (point)""points to write ("" = all)

Writes: point (or vertex) float <name> (vec3 for channel rgb)

Example

{
  "type": "attribute_from_map",
  "in": ["ground_pts"],
  "params": {
    "path": "density.png",
    "projection": "xz",
    "size": [100, 100],
    "name": "density"
  }
}

cluster#

aliases: pcg_cluster kmeans clusterpoints cluster_points

Cluster points: k-means (count clusters) or by radius; writes an int cluster id (optionally the cluster centre and a debug colour). Piece assignment, grouping scattered objects, LOD cells.

Houdini: Cluster Points SOP (k-means, attribute "cluster"); Unreal PCG: no direct node (use cluster ids with Attribute Partition). kmeans: seeded k-means++ start, then Lloyd iterations (stops when nothing changes); radius: leader clustering, points visited in a seeded random order take every unassigned point within radius, so each cluster fits in a ball of that radius. Cluster ids are numbered in point order (cluster 0 holds the first point). center writes cluster_center (the centroid of the cluster); color writes Cd per cluster for a debug render. Points outside group get cluster -1. Packed instances are clustered by their anchors.

Inputs

#namedescription
0pointspoints (or any geometry: its points are clustered)

Parameters

nametypedefaultrangedescription
methodenum"kmeans"k-means with count clusters, or radius clusters
options: kmeans radius
aliases: mode
countint81..100000kmeans: number of clusters
aliases: clusters k num_clusters
iterationsint101..1000kmeans: Lloyd iterations at most
aliases: iter
radiusfloat10..radius: cluster radius in metres
seedfloat0random seed
namestring"cluster"output point int attribute
aliases: attrib output
centerboolfalsealso write cluster_center (vec3)
aliases: write_center cluster_center
colorboolfalsealso write Cd per cluster (debug view)
aliases: colorize visualize
groupgroup (point)""points to cluster ("" = all); the others get -1

Writes: point int cluster (or <name>); optional cluster_center, Cd

Example

{
  "nodes": {
    "g": { "type": "grid", "params": { "size": [20, 20] } },
    "s": { "type": "scatter", "in": ["g"], "params": { "count": 400 } },
    "c": {
      "type": "cluster",
      "in": ["s"],
      "params": { "count": 6, "color": true }
    }
  },
  "output": "c"
}

mask#

aliases: pcg_mask scatter_mask mask_by_feature maskbyfeature point_mask

Write a 0..1 point mask from a feature (slope, height, curvature, occlusion, distance, direction, noise, attribute, group, inside), shaped by a band with falloff and a ramp, and combined with an existing mask. Feed scatter density_mask or prune.

Houdini: Mask by Feature / attribute from features; Unreal PCG: Density Filter inputs (Normal To Density, Distance, Spatial Noise). The feature value v becomes 1 inside [min, max] and fades linearly to 0 over falloff outside it (a hard edge when falloff is 0), then ramp reshapes it, invert flips it, and combine merges it with the existing mask attribute (replace, multiply = and, max = or, add, subtract, min). Units of min/max per feature: slope = degrees between N and up (0 flat, 90 vertical; default 0..30 = gentle ground); height = metres along up (Y); curvature = mean curvature in 1/m (positive convex: ridges, bumps; negative concave: valleys); occlusion = 0..1 ambient occlusion (rays against the geometry and input 1); distance = metres to input 1 (mesh, curves or points; e.g. away from a road: min 3, max 1e9); direction = degrees between N and direction (e.g. north faces); noise = 0..1 fractal noise (frequency, octaves, seed); attribute = the value of source_attrib (first component); group = 1 for points matching pattern; inside = 1 inside input 1's closed mesh (falloff = soft edge in metres outside it). Normals: the point N, else for a point cloud the normal of input 1 at the closest point, else computed from the polygons. Packed instances keep their anchors.

Inputs

#namedescription
0geopoints or mesh to mask (the mask is a point attribute)
1referencedistance / inside: what to measure to; slope, direction, curvature, occlusion of a point cloud: the surface it lies on (optional)

Parameters

nametypedefaultrangedescription
byenum"slope"feature to mask by
options: slope height curvature occlusion distance direction noise attribute group inside
aliases: feature type
minfloat0lowest feature value with mask 1 (units depend on by)
aliases: min_value low
maxfloat30highest feature value with mask 1
aliases: max_value high
fallofffloat00..linear fade outside [min, max] in feature units (inside: metres outside the mesh); 0 = hard edge
aliases: fade soft
rampramp[[0,0],[1,1]]reshape the 0..1 mask before combining
invertboolfalseinvert the feature mask (1 - mask) before combining
combineenum"replace"merge with the existing mask attribute: multiply = and, max = or (missing attribute = start from scratch)
options: replace multiply add subtract max min
aliases: mode operation blend
namestring"mask"output point float attribute
aliases: output output_attrib mask_name
upvec3[0,1,0]slope: the "flat" normal; height: the axis heights are measured along
aliases: up_vector axis
directionvec3[1,0,0]direction: the facing direction measured against N (angle in degrees)
aliases: facing
source_attribstring""attribute: the point attribute to read (vectors: first component)
aliases: from_attrib input_attrib feature_attrib
patterngroup (point)""group: point group pattern that gets 1 (e.g. "top", "@P.y>2")
frequencyfloat0.20..noise: spatial frequency (1/m)
aliases: freq
octavesint31..8noise: fractal octaves
samplesint161..256occlusion: rays per point
aliases: rays
max_distancefloat00..occlusion: rays only count hits closer than this (0 = unlimited)
aliases: radius maxdist
seedfloat0random seed
groupgroup (point)""points to write ("" = all); the others keep their mask (0 when new)

Writes: point float mask (or <name>)

Example

{
  "nodes": {
    "land": { "type": "terrain", "params": { "size": [60, 60], "height": 8 } },
    "flat": {
      "type": "mask",
      "in": ["land"],
      "params": { "by": "slope", "min": 0, "max": 20, "falloff": 10 }
    },
    "low": {
      "type": "mask",
      "in": ["flat"],
      "params": {
        "by": "height",
        "min": -100,
        "max": 4,
        "falloff": 1,
        "combine": "multiply"
      }
    },
    "pts": {
      "type": "scatter",
      "in": ["low"],
      "params": {
        "generate_by": "density",
        "density": 0.5,
        "density_mask": "mask"
      }
    }
  },
  "output": "pts"
}

orient#

aliases: pcg_orient align orient_points transform_points

Orient points for instancing: write orient (quaternion), N and up from the point normal + up, a surface (input 1), the nearest curve tangent (RMF), a fixed direction, a look-at target or random rotations; plus random yaw, tilt and scale ranges.

Houdini: Attribute Randomize (orient, pscale) + Orient Along Curve + Scatter and Align; Unreal PCG: Transform Points (rotation and scale ranges). Frame convention as copy_to_points: +Z = N, +Y = up. mode gives the main direction: normal_up = the point N (and the point up, else the up param); surface = the normal of input 1 (or of the input's own polygons) at the closest point (snap moves the points onto it); curve_tangent = the tangent of the closest curve of input 1 (or of the input's own curves) with a rotation-minimising up; direction = the direction param; look_at = towards target; random = a random rotation of up to max_angle about axis ([0,0,0] = any axis) applied to the normal_up frame. align_axis z (default) puts the main direction on +Z (N) and makes the up param perpendicular for +Y; align_axis y puts it on +Y (upright models such as trees, rocks or posts follow the surface) and takes +Z from the direction param (the up param in direction mode). upright keeps +Y on the up param and only turns the heading (posts along a sloped road). Then random_yaw turns about the instance's +Y and tilt leans it by an angle in the range towards a random side (degrees). Scale: scale_min..scale_max, random per point or picked by scale_attrib (0..1, e.g. a mask): uniform → pscale, per axis → scale. Points outside group keep their attributes.

Inputs

#namedescription
0pointspoints to orient
1referencesurface (mode surface) or curves (mode curve_tangent) (optional)

Parameters

nametypedefaultrangedescription
modeenum"normal_up"where the main direction comes from
options: normal_up surface curve_tangent direction random look_at
align_axisenum"z"instance axis that follows the main direction: z = N (Houdini copy), y = up (upright models)
options: z y
aliases: axis_mode align_to
upvec3[0,1,0]reference up (+Y) when the main direction drives +Z
aliases: up_vector
directionvec3[0,0,1]mode direction: the main direction; align_axis y: the reference for +Z
aliases: dir heading
targetvec3[0,0,0]look_at: the point instances face
aliases: look_at_point
axisvec3[0,1,0]random: rotation axis ([0,0,0] = a random axis per point)
max_anglefloat1800..180random: largest rotation in degrees (either way)
random_yawvec2[0,0]random turn about the instance up axis, degrees [min, max] (e.g. [0, 360])
aliases: yaw random_heading rotation_range
tiltvec2[0,0]random lean away from up, degrees [min, max], towards a random side
aliases: random_tilt lean
scale_minvec3[1,1,1]smallest scale (a number for all axes)
aliases: min_scale
scale_maxvec3[1,1,1]largest scale
aliases: max_scale
uniform_scalebooltrueone random factor (x component of the range) → pscale; off: per-axis factors → scale
scale_attribstring""point attribute 0..1 picking the scale between min and max instead of a random value (a scale ramp by mask)
uprightboolfalsekeep +Y on the up param: only the heading (+Z projected onto the horizontal plane) follows the mode (lamp posts on a sloped road, buildings)
aliases: keep_upright yaw_only
snapboolfalsesurface: move the points onto the surface
writeenum"both"attributes to write: orient + N + up, only orient, or only N + up
options: both orient n_up
seedfloat0random seed
groupgroup (point)""points to orient ("" = all)

Writes: point orient (quaternion), N, up; pscale or scale when a scale range is set

Example

{
  "nodes": {
    "ground": { "type": "grid", "params": { "size": [20, 20] } },
    "pts": { "type": "scatter", "in": ["ground"], "params": { "count": 200 } },
    "o": {
      "type": "orient",
      "in": ["pts"],
      "params": {
        "mode": "direction",
        "align_axis": "z",
        "random_yaw": [0, 360],
        "tilt": [0, 8],
        "scale_min": 0.7,
        "scale_max": 1.3
      }
    }
  },
  "output": "o"
}

Used in the example guided_town.

points_along_curve#

aliases: pcg_spline_sampler curve_points spline_sampler points_along_spline sample_curve

Points along curves at a spacing (metres, with start/end offsets), a count, per segment or at the curve points; writes curveu, tangent, N, up (rotation-minimising), orient and curve_id. Lamp posts, fence posts, road markings.

Houdini: Resample (+ Orient Along Curve) to points; Unreal PCG: Spline Sampler (distance / subdivision modes). mode distance: points every spacing metres of arc length from start_offset to the curve length − end_offset (count > 0 instead spreads exactly count points evenly over that range); subdivision: per_segment points on every segment (the vertices and evenly between them); at_points: one point per curve vertex. jitter moves points randomly by up to ±jitter metres along the curve. side_offset shifts them sideways (positive = right of the direction of travel, T × up), both_sides adds the mirrored point on the left (side = -1). Attributes: curveu (0..1 of the arc length), tangent = N (unit, along the curve), up (rotation-minimising frame starting from the up param), orient (+Z along the curve), curve_id (source prim); source point attributes are interpolated and prim attributes copied. Closed curves (polygons) are walked as loops.

Inputs

#namedescription
0curvespolylines or polygons (outlines); Bezier/NURBS curves are sampled adaptively

Parameters

nametypedefaultrangedescription
modeenum"distance"distance = by spacing (or count); subdivision = per segment; at_points = the curve vertices
options: distance subdivision at_points
spacingfloat10.0001..distance: metres of arc length between points
aliases: step length seglen distance
countint00..5000000distance: exactly this many points per curve, evenly spread (0 = use spacing)
aliases: npts points
per_segmentint11..10000subdivision: points per segment
aliases: segments subdivisions
start_offsetfloat00..skip this many metres at the start
aliases: start
end_offsetfloat00..skip this many metres at the end
aliases: end
jitterfloat00..random move along the curve, metres (±)
side_offsetfloat0sideways offset in metres (positive = right of the direction of travel)
aliases: offset lateral_offset
both_sidesboolfalsealso place the mirrored point on the other side (side_offset ≠ 0)
upvec3[0,1,0]up vector the rotation-minimising frame starts from
aliases: up_vector
seedfloat0random seed
groupgroup (prim)""curves to sample ("" = all)

Writes: points: curveu, tangent, N, up, orient, curve_id (side with a side offset); source point/prim attributes

Example

{
  "nodes": {
    "road": {
      "type": "curve",
      "params": {
        "points": [[-20, 0, -5], [0, 0, 5], [20, 0, 0]],
        "smooth": true
      }
    },
    "lamps": {
      "type": "points_along_curve",
      "in": ["road"],
      "params": {
        "spacing": 8,
        "start_offset": 2,
        "side_offset": 4,
        "both_sides": true
      }
    }
  },
  "output": "lamps"
}

Used in the examples guided_town, market_street, rail_along_curve.

prune#

aliases: pcg_prune self_prune bounds_prune density_filter self_pruning point_filter

Remove points: overlapping spheres (pscale × radius; largest or random wins), a random fraction by a mask (density filter), an attribute expression (@mask<0.5), or points near / inside other geometry (input 1).

Unreal PCG: Self Pruning (overlap), Density Filter (density), Attribute Filter (expression), Difference / Bounds Modifier (near_geometry); Houdini: Delete by expression, Fuse/Scatter relax. overlap: each point is a sphere of radius × pscale (radius alone without use_pscale or pscale); spheres are kept in priority order (largest first, smallest first, random, point order, or by priority_attrib, highest first) and any sphere overlapping a kept one is removed, so no two kept spheres overlap (exact). density: keep each point with probability attrib × fraction (seeded; a missing attrib counts as 1). expression: remove points matching a point group pattern (@mask<0.5, "@P.y>3 @height<0.2" = either, "!top"). near_geometry: remove points within distance of input 1 (mesh surface, curves or points) and, with inside, points inside its closed polygons (e.g. buildings, roads). invert keeps what would be removed. Points outside group are kept and do not take part. Removing a point removes the prims using it; packed instances go with their anchor points.

Inputs

#namedescription
0pointspoints to prune
1blockernear_geometry: the geometry points must keep away from (optional)

Parameters

nametypedefaultrangedescription
modeenum"overlap"how to choose the points to remove
options: overlap density expression near_geometry
radiusfloat0.50..overlap: sphere radius in metres (times pscale)
aliases: rad bounds_radius
use_pscalebooltrueoverlap: multiply radius by the point pscale
priorityenum"largest"overlap: which sphere wins (ties are broken randomly)
options: largest smallest random order attribute
priority_attribstring""overlap, priority attribute: point attribute, highest value wins
attribstring"mask"density: keep probability attribute (0..1)
aliases: density_attrib mask_attrib
fractionfloat10..density: multiplies the keep probability (0.3 = keep about 30% where the mask is 1)
aliases: keep_fraction ratio
expressionstring"@mask<0.5"expression: point group pattern of the points to remove
aliases: expr filter
distancefloat10..near_geometry: remove points closer than this to input 1 (metres)
aliases: dist clearance
insidebooltruenear_geometry: also remove points inside input 1's closed polygons
invertboolfalsekeep the points that would be removed instead
seedfloat0random seed
groupgroup (point)""points to test ("" = all); the others are kept

Writes: the kept points (and the prims whose points all survive)

Example

{
  "nodes": {
    "g": { "type": "grid", "params": { "size": [10, 10] } },
    "s": {
      "type": "scatter",
      "in": ["g"],
      "params": { "count": 300, "relax": false }
    },
    "o": {
      "type": "orient",
      "in": ["s"],
      "params": { "mode": "direction", "scale_min": 0.5, "scale_max": 1.5 }
    },
    "p": {
      "type": "prune",
      "in": ["o"],
      "params": { "mode": "overlap", "radius": 0.3 }
    }
  },
  "output": "p"
}

Used in the examples guided_town, market_street.