Terrain Material and HeightField Mask in Solaris
2026-11-12
Terrain Material and HeightField Mask in Solaris
Step-by-step technique: build a full material from a Megascans map set, then derive a mask from heightfield erosion, write it out as EXR, and blend a second layer by that mask directly inside the shader. Written for Houdini 22 (Solaris / MaterialX / Karma XPU).
0. Overview
The technique has three independent parts. A layer (gravel, rock, sand) is the same set of nodes with different texture paths, so the second and third layers are built by copying.
SOP /obj/<terrain> LOP /stage
------------------- -----------------------------------------
heightfield (height, mask) Material Library
-> heightfield_erode -> Karma Material Builder <mat>
-> heightfield_blur -> MtlX Standard Surface
-> heightfield_output --> EXR -> Assign Material (/materials/<mat>)
<mask_exr> |
current scene -> ... -> TERRAIN (sopimport)
Inside the material, two layers live side by side and are blended by the same mask:
layer A (gravel) ---\
MtlX Mix (fg = layer B, bg = layer A, mix = mask) -> Standard Surface
layer B (rock) ---/
1. Naming and paths
| Placeholder | Meaning | Example |
|---|---|---|
<mat> |
Material name in snake_case | gravel_ground |
<tex_dir> |
Folder of the downloaded Megascans set | gravel_ground_xdynafj_4k |
<tex_prefix> |
File name up to the map suffix | Gravel_Ground_xdynafj_4K |
<terrain> |
SOP object holding the heightfield | /obj/HF |
<mask_exr> |
Exported mask | $HIP/textures/terrain_mask.exr |
| Element | Name / path |
|---|---|
| Source textures | $HIP/textures/<tex_dir>/ |
| Material Library (LOP) | /stage/materiallibrary1 |
| Karma Material Builder | /stage/materiallibrary1/<mat> |
| USD material path | /materials/<mat> |
| Map nodes | img_basecolor, img_roughness, img_normal, … |
| Second-layer nodes | the same names with a _2 suffix |
Tip. Megascans sets ship with the suffixes
_BaseColor,_Roughness,_Gloss,_AO,_Cavity,_Specular,_Normal,_Bump,_Displacement. Sets vary: plants are missing half of those maps, terrain has almost all of them. Build only the maps that actually exist in the folder.
2. Material skeleton (Karma Material Builder)
Drop a Material Library in /stage, go inside and create a Karma Material Builder named <mat>. It already contains an MtlX Standard Surface and the Material_Outputs_and_AOVs output — do not recreate them.
Nodes every layer is built from:
| Node | Type | Purpose |
|---|---|---|
texcoord_tiling |
mtlxtexcoord |
Mesh UV0 |
uv_place2d |
mtlxplace2d |
Tiling and offset of the maps |
img_<map> |
mtlximage |
One node per map |
inv_gloss |
mtlxinvert |
Gloss -> roughness |
mix_roughness |
mtlxmix |
Roughness + inverted Gloss |
mult_ao, mult_cavity |
mtlxmultiply |
Multiply color by AO and cavity |
normalmap |
mtlxnormalmap |
Normal map -> normal vector |
bump |
mtlxbump |
Height + normal |
mtlxdisplacement |
mtlxdisplacement |
Displacement map |
Every map of a layer takes UV from a single uv_place2d node (its texcoord input). Tiling lives there: scale, rotate, offset.
Warning. In H22
mtlxtexcoordhas no UV-set parameter: the node always outputs UV0. If the geometry carries several sets, they have to be blended with amtlxtexcoordplus a wrangle before import — do not look for a "UV Set" field.
3. Connecting the maps
Every map is its own MtlX Image. Three fields always matter:
| Field | What to set |
|---|---|
| File | $HIP/textures/<tex_dir>/<tex_prefix>_<Map>.jpg |
| Signature | Color for color, Float for data, Vector 3 for normals |
| File Color Space | sRGB - Texture for color, Raw for data |
| Map | Signature | Color Space | Connect to |
|---|---|---|---|
| BaseColor | Color | sRGB - Texture | -> mult_ao.in1 |
| AO | Color | Raw | -> mult_ao.in2 |
| Cavity | Color | Raw | -> mult_cavity.in2 |
| Roughness | Float | Raw | -> mix_roughness.fg |
| Gloss | Float | Raw | -> inv_gloss.in |
| Specular | Float | Raw | -> mult_specular.in1 |
| Normal | Vector 3 | Raw | -> normalmap.in |
| Bump | Float | Raw | -> bump.height |
| Displacement | Float | Raw | -> mtlxdisplacement.displacement |
The chains:
base_color : img_basecolor -> mult_ao.in1
img_ao -> mult_ao.in2
mult_ao -> mult_cavity.in1
img_cavity -> mult_cavity.in2
mult_cavity -> mtlxstandard_surface.base_color
roughness : img_roughness -> mix_roughness.fg
img_gloss -> inv_gloss -> mix_roughness.bg
mix_roughness -> mult_roughness.in1 -> specular_roughness
specular : img_specular -> mult_specular.in1 -> specular
normal : img_normal -> normalmap -> bump.normal
bump : img_bump -> bump.height
bump -> mtlxstandard_surface.normal
displacement: img_displacement -> mtlxdisplacement
- AO and Cavity go into color through multiply nodes, not dedicated inputs — that keeps their strength controllable.
- A
multiplyormixstarts with one input connected; leave the second as a constant (for examplemult_roughness.in2 = 1). That constant is your strength knob. bumpis already wired to the shader'snormalinput; itsheightinput takes the map, itsnormalinput takes thenormalmapresult.
Tip. Before its first connection,
MtlX Mixsits in theFloatsignature and exposesfg/bg/mixas floats. Set Signature up front:Colorto blend two colors,Vector 3to blend normals. Skip that and a color map is silently converted to float and the material looks flat.Tip. Always set File Color Space explicitly, even when Houdini guesses right. Empty means heuristics: they change between versions and silently darken or brighten the layer.
4. Mask from the heightfield
4.1 The mask layer in SOPs
Erosion produces the mask: heightfield_erode writes a mask layer into the heightfield. The mask is usually blurred so the edge stays soft:
heightfield -> heightfield_erode -> heightfield_maskbyfeature -> heightfield_blur -> output
Confirm the layers are there in the Spreadsheet, or with a Volume Wrangle reading @mask. The range is always 0-1.
4.2 Export (HeightField Output)
One node per mask, its input is the last node of the mask branch:
| Parameter | Value | Why |
|---|---|---|
| Output Type | Packed Raster | A 2D image, not geometry |
| Format | RGB (or RGBA) | The mask lands in R; Single Channel writes it to A, which is awkward |
| Type | 16b Floating Point | Enough for a mask and half the weight of fp32 |
| Resolution | from the heightfield | Leave Specify Res off so nothing drifts |
| Output File Sequence | off | One frame, one file |
| Filename | $HIP/textures/<mask_exr> |
Absolute paths do not travel between machines |
| Fill Red | on, Red = mask |
Layer names are case-sensitive |
| Output Range | No Remapping | The mask is already 0-1 and auto-remap would break the values |
| Flip Vertically | see below | Depends on how UV landed on the mesh |
Press Save to Disk. Verify with file statistics:
500 x 500, 3 channel, half openexr
Min 0 / Max 1 / Avg 0.17 <- the average must match the mean of the mask layer in the heightfield
Warning. Flip Vertically is not a universal checkbox. If the image was written without a flip and the mask landed correctly on the terrain, flipping it breaks the alignment. Check once for this setup and leave it alone: either lock the toggle in the node or re-save the file after every change.
Tip. When the mask is needed as an attribute in the scene (scatter masks, vertex colors),
convertheightfieldcopies every layer to point attributes:mask,height,sediment,debris,flow. The UV it produces covers the whole terrain 0-1, so texture and mesh line up 1:1 without a place2d.
5. Blending the second layer
5.1 Duplicating the map set
- Copy every
img_*node of layer A, rename toimg_*_2, replace the paths with<tex_dir_2>. - Make a second UV branch:
texcoord_tiling1->uv_place2d1. The second layer almost always needs its own tiling — otherwise both textures show the same pattern and the blend reads as a seam. - Connect
uv_place2d1to thetexcoordinput of every_2map.
5.2 The mask in the shader
One node per mask, connected straight to UV0, no place2d:
| Parameter | Value |
|---|---|
| File | <mask_exr> |
| Signature | Float (reads the R channel) |
| File Color Space | Raw |
| texcoord | mask_texcoord (mtlxtexcoord) |
Warning. Never feed the mask through the second layer's
uv_place2d: the mask is tied to the terrain 1:1 and tiling multiplies it.
5.3 Blending per channel
Every channel blends through its own node, all of them driven by the same mask:
| What is blended | Node | fg | bg | mix |
|---|---|---|---|---|
| BaseColor | mix_basecolor |
img_basecolor_2 |
img_basecolor |
mask |
| AO | mix_ao |
img_ao_2 |
img_ao |
mask |
| Cavity | mix_cavity |
img_cavity_2 |
img_cavity |
mask |
| Specular | mix_specular |
img_specular_2 |
img_specular |
mask |
| Bump | mix_bump |
img_bump_2 |
img_bump |
mask |
| Displacement | mix_displacement |
img_displacement_2 |
img_displacement |
mask |
| Normal | mix_normal |
normalmap_2 |
normalmap |
mask |
fg is layer B and bg is layer A: mask 1 shows the second layer, mask 0 keeps the base one. That is also the MtlX Mix default.
Wiring:
base_color : mix_basecolor -> mult_ao.in1 -> mult_cavity -> base_color
AO/Cavity : mix_ao -> mult_ao.in2 , mix_cavity -> mult_cavity.in2
specular : mix_specular -> mult_specular.in1
normal : normalmap_2 ----\
normalmap ----- mix_normal -> normalize_normal -> bump.normal
bump : mix_bump -> bump.height
displace : mix_displacement -> mtlxdisplacement
Warning. Blend basecolor before AO and Cavity. Blending the second layer after the AO multiply leaves that texture without shadowing and opens a lighting seam at the border.
5.4 Roughness of the second layer
Roughness cannot be mixed directly: each layer has its own Roughness + inverted Gloss pair. Build the second layer first, then blend the results:
img_gloss_2 -> inv_gloss_2 \
mix_roughness_2 (fg = roughness_2, bg = inv_gloss_2)
img_roughness_2 ------------/
mix_roughness_2 ---\
mix_roughness_both -> mult_roughness.in1 -> specular_roughness
mix_roughness -----/
Otherwise roughness jumps at the border: one layer's gloss gets mixed into the other layer's roughness.
5.5 Normals
A normal is a vector, not a color. Blending two normal maps as images breaks the unit length of the vector and the surface starts to "float".
img_normal_2 -> normalmap_2 ---\
mix_normal (Signature = Vector 3, mix = mask)
img_normal -> normalmap ----> normalize_normal -> bump.normal
Both layers share the same tangent space (the UVs are common), so blending in tangent space is valid. mtlxnormalize restores unit length — without it the blend leaves a dark band at the border.
Tip. Keep
normalmapScale at 1. Boost relief after the blend with one shared multiplier, otherwise the layers end up with different strength.
5.6 Strength
When the mask should act as a 0-1 dial instead of full on/off, insert a single mtlxmultiply between the mask and every mix input:
mask -> mtlxmultiply.in1
1.0 -> mtlxmultiply.in2 (this is the strength)
One node, one knob for the whole material instead of ten.
6. Assigning the material in Solaris
- The material already lives in
/stage/materiallibrary1/<mat>; its USD path is/materials/<mat>. - Put an Assign Material LOP after the Material Library.
- Primitives — the terrain geometry pattern, for example
/World/terrainor*. - Material Path — the USD path
/materials/<mat>.
Warning. A node path (
/stage/materiallibrary1/<mat>) does not work in Assign Material: the geometry stays gray and the log stays silent.
7. Lighting and checks in Karma XPU
- Render with Karma XPU; the CPU default can hide an unsupported node.
- Early viewport samples look noisy and flat — judge the material once it converges.
- The mask is data: if it is accidentally set to sRGB - Texture, the border gets harder and darker.
- Two 4K sets mean 8-10 maps of 30-70 MB each in render memory. If RAM is tight, convert to
.rat/.txor use 2K.
8. Troubleshooting
| Symptom | Cause / fix |
|---|---|
| Material is gray, no errors | Assign Material points at a node path instead of /materials/<mat>. |
| Color too dark or washed out | File Color Space empty or wrong: color maps need sRGB - Texture, data maps Raw. |
| Second layer never appears | The mask is not connected to mix, or MtlX Mix is still in the Float signature. |
| Mask drifts across the terrain | The mask is fed through the second layer's uv_place2d; it needs plain UV0. |
| Mask pattern is mirrored | Toggle Flip Vertically in HeightField Output and re-save the EXR. |
| EXR is written but the shader sees nothing | The mask is in channel A (Format = Single Channel) while MtlX Image with Signature Float reads R. Write RGB. |
| Values are within 0-1 but the mask looks posterized | Auto Remap is left on in Output Range and the mask was normalized by min/max. Set No Remapping. |
| Lighting seam at the layer border | Basecolor was blended after AO/Cavity. Blend before the multiply. |
| Dark band at the border in the normals | No mtlxnormalize after the vector blend. |
| Roughness jumps at the border | Roughness and Gloss were blended separately instead of building the pair per layer. |
| Textures look blurry or repeat | No tiling: uv_place2d is not connected to the maps' texcoord. |
| Mask average does not match the heightfield | Wrong layer name (mask vs Mask) or auto-remap left on. |
9. Checklist for a new layer
- Lay out the set in
$HIP/textures/<tex_dir>/and check which maps actually exist. - Material: MtlX Standard Surface,
texcoord_tiling->uv_place2d, oneMtlX Imageper map. - Set Signature and Color Space from the table in section 3.
- Build the chains: basecolor -> AO -> Cavity; Roughness + inverted Gloss -> Mix; Normal -> Normalmap -> Bump; Displacement.
- Test the material on a single shader in the Karma XPU viewport before duplicating the set.
- Mask in SOPs: erosion -> mask by feature -> blur -> HeightField Output (Packed Raster, RGB, fp16, Red = mask, No Remapping).
- Save to Disk, compare the file's min/max/avg with the layer in the heightfield, check its orientation.
- Second layer: copies of the maps with
_2, its own UV branch, oneMtlX Imagefor the mask (Float, Raw, UV0). - Blend each channel through its own node: basecolor before AO, roughness after building the pair, normals through vector blend plus normalize.
- Verify Assign Material with the
/materials/<mat>path and a final frame in Karma XPU.