NormalMapProvider
constNormalMapProvider:MaterialEffectClass<{normalMap: () =>Texture<unknown> |null; }>
Defined in: packages/presets/src/lighting/NormalMapProvider.ts:36
Provides the ‘normal’ and ‘elevation’ channels from a pre-baked normal atlas.
Atlas encoding (see @three-flatland/normals/bakeNormalMap):
R = nx ∈ [-1, 1] → mapped from [0, 255]
G = ny ∈ [-1, 1] → mapped from [0, 255]
B = elevation ∈ [0, 1] → mapped from [0, 255]
A = source alpha
The provider reconstructs nz = sqrt(max(0, 1 − nx² − ny²)) at
runtime — outward-facing tangent-space convention means nz ≥ 0 always,
so the sign is implicit and one texture channel is freed for elevation.
Instance-flip correction: sampled normal.xy is multiplied by the
existing instanceFlip attribute so a flipX/flipY sprite responds
to lights from the geometrically-correct side.
Elevation drives DefaultLightEffect’s per-fragment light direction
(L.z = lightHeight − elevation). Different normalMap textures
produce different materials and therefore different batches.
Example
Section titled “Example”import { NormalMapProvider } from '@three-flatland/presets'
const provider = new NormalMapProvider()provider.normalMap = myNormalMapTexturesprite.addEffect(provider)