mx_heighttonormal
Convenience node that converts a height signal to a normal vector. It coerces the input to vec3 and the strength to float, then delegates to bumpMap for the perturbation.
Core Advantages
One‑liner for a common task: type‑safe wrapping plus reuse of bumpMap math, so height textures or procedural heights plug straight into a material’s normal.
Common Uses
Generate normals on the fly from grayscale height textures.
Turn procedural noise into normals for water, rock, leather micro‑details.
Provide a lightweight substitute or complement to normalMap when only height data is available.
Blend with an existing normal map to boost or damp bump detail.
How to adjust
Tune scale as the main lever: positive = convex, negative = concave; larger magnitude = stronger perturbation. Inputs may be float/vecN; the node coerces to vec3 before calling bumpMap. For colored height sources, pick a single channel or apply grayscale() first. To combine with an existing normal map, mix(normalMap(...), mx_heighttonormal(...), mask). The material socket is material.normalNode.
Code Examples
1<mesh>
2 <sphereGeometry args={[0.4, 128, 128]} />
3 {/* Convert height to normal and feed the material */}
4 <meshStandardNodeMaterial
5 normalNode={mx_heighttonormal( texture(heightMap).r, float(0.75) )}
6 />
7</mesh>
8
9// JS variant:
10const n = mx_heighttonormal( texture( heightMap ).r, 0.75 );
11material.normalNode = n; // hook into the material normal input