Skip to content

normalFromHeight

normalFromHeight(heightTex, uv, strength?, texelSize?): Node <"vec3">

Defined in: packages/nodes/src/lighting/normalFromHeight.ts:20

Generate a normal map from a heightmap texture. Uses Sobel-like sampling to compute surface normals from grayscale height data.

Texture 

Heightmap texture (grayscale, white = high, black = low)

Node <"vec2">

UV coordinates to sample

FloatInput = 1

Normal strength multiplier (default: 1)

Vec2Input

Size of one texel in UV space, or calculated from texture dimensions

Node <"vec3">

Normal vector in tangent space (vec3, -1 to 1 range)

// Generate normals from heightmap
const normals = normalFromHeight(heightmap, spriteUV, 2.0)