The terrain nodes (prefix TERA) are the largest group I have, at 107.
They do not fall apart at that size because the data they pass, the way they are built and the place settings live are all the same.
What they pass: a heightfield
Nodes pass Houdini's standard heightfield to each other.
A heightfield is a stack of 2D volumes (height, masks, color channels, flow and so on), each found by the name in its name attribute. There are shared functions to find a layer or create it if missing.
GU_PrimVolume* findHeightfieldLayer(GU_Detail* gdp, const char* layerName);
GU_PrimVolume* ensureHeightfieldLayer(GU_Detail* gdp, GU_PrimVolume* heightPrim, /* ... */);Three layers
The structure has three layers:
- Core: types and parameter definitions.
- GPU: OpenCL compute and the CPU fallback.
- SOP: a thin Houdini wrapper that holds only parameters, the cook and errors.
The rule is "no algorithms in the SOP".
One SOP is one DLL, and all of them link a shared static library, TERA_GPU. OpenCL kernels are embedded in the DLLs, so there are no extra files to ship.
Families of nodes
Grouped by folder name, the nodes fall roughly into these families:
- Generate: Mountain, Noise, Canyon_Mesa, Dune, Ridge, Crater
- Erosion and weathering: Hydraulic, Thermal, Coastal_Erosion, Glacial_Erosion, Gully_Erosion, Wind_Abrasion
- Shaping: Terrace, Slump, Crack, Cliff_Retreat, Stamp
- Water: Flow, River, River_Network, Riverbank, Lakes
- Analysis and masks: Slope, Curvature, Aspect, Sun_Exposure, Wetness
- Surface and color: Smart_Surface, Tint, Texture, Snow, Seasonal
- Placement: Scatter, Rock_Distribution, Scree, Forest, Grass
- Tiles and export: Tile_Split, Tile_Merge, Seamless, Output, Mesher, UnrealLandscape
Application area is the same everywhere
Every node that produces height has an "Application Area" folder.
You can choose the entire terrain, paint, closed curves, a curve path or an input mask, and with the default "Entire Terrain" the output does not change. For masks, white applies and black keeps.
Because the same control narrows the area on every node, there is only one thing to learn.
Split into tiles, then join
Large terrains are processed in tiles.
To avoid steps at the borders, tiles are cut out with overlap (padding), processed, then cropped back and blended.
struct TileGrid {
int countX = 1;
int countY = 1;
float overlapAmount = 0.25f;
};
// padding voxels = overlap * min(tileResX, tileResY) * 0.5
float computePaddingVoxels(int fullResX, int fullResY, const TileGrid& grid);The tricky part was cropping back.
The crop width must be computed from the window that was actually extracted. Computing it from the resampled resolution crops too much and leaves gaps or overlaps. A one-voxel gap that can appear when tiles are cropped has a dedicated fix (setCloseTileGaps).
Parameters live in one place
Parameters are collected as structs in Core/Common/Params.h.
SOPs read from there and build their UI with the builder.
struct DetailTransferParams {
static constexpr float maxRadius = 100.0f;
char field[64] = "height";
char maskField[64] = "mask";
float radius = 10.0f;
float erasure = 1.0f;
bool useMask = false;
bool useGPU = true;
};The rules are these.
The maximum for a spatial size is 100, every numeric parameter gets a range and is also clamped inside the cook, and names are snake_case like height_layer.
A case that broke with resolution
The flow node broke when the terrain resolution went up.
The particle cap was still 1 million, which was not enough for the 4096² defaults. After raising the cap to 8,388,608, a single cook took 1.02 s at 4096² and 2.56 s at 8192² (single measurements that include the first compile).
Summary
The set stayed intact as it grew not because the nodes are clever but because they are built the same way.
Once the data hand-off, the layers, the application area and the parameter home are fixed, the 108th node is written the same way as the first.
Next: the plant and cliff nodes.
Comments