Skip to content

Materials

material is a discriminated union on shader. Each model accepts only its own options. All accept roughness and roughnessScale. Every numeric option takes a plain number, a PhotonValue, or a callable signal.

OptionTypeDefault
ambientnumber0.2
OptionTypeDefault
ambientnumber0.2
shininessnumber32
highlightColorstringwhite
OptionTypeDefault
ambientnumber0.2
stepsnumber3
smoothnessnumber0.1
OptionTypeDefault
shininessnumber32
highlightColorstringwhite

Takes no ambient.

OptionTypeDefault
ambientnumber0.2
shininessnumber32
smoothnessnumber0.1
highlightColorstringwhite
grainnumber0
grainScalenumber0.5
grainType'dot' | 'line''line'

Fabric’s own model. Not the same as glass’s anisotropy, which smears a background sample rather than shading a surface.

OptionTypeDefault
roughnessnumber0
roughnessScalenumber0.5

On a lit shader roughness bumps the normal with noise at roughnessScale frequency. On glass it blurs the refracted image instead — see below.

shader: 'glass' moves the shape to its own pipeline. Instead of lighting a surface it refracts the frame — Glass walks the ten stages. The options are listed here in the order the shader uses them.

<Box position={[1.42, -2, -1.52]} size={{ x: 0.6, y: 0.6, z: 0.6 }} roundness={0.4} color="#e70ae7"
material={{
shader: 'glass',
thickness: 2, ior: 1.09, fresnel: 9, fresnelColor: '#ffffff', outline: 0.4,
attenuationDistance: 100, attenuationColor: '#ffffff',
}} />

Two of the shape’s own props change meaning on glass:

Shape propOn a glass shape
colorA tint multiplied into the refracted image. Default white — no tint.
opacityThe tint’s strength, 0–1, default 0.9. Not transparency: a glass shape always covers its pixels.
OptionDefaultWhat it does
ior1.5Index of refraction. The ray bends by 1/ior entering and by ior leaving; values below 1.0001 are clamped. Also sets the base reflectance metalness uses.
thickness0.3World units the exit ray travels before the backdrop is read — the lever on how far the image shifts. 0.3–0.6 reads as glass, 1–3 as a lens.
refraction'volume''volume' bends at the front, walks the shape’s real depth to the back surface and bends again there. 'slab' bends once and walks thickness from the front — three.js’s model: thin edges bend as hard as the middle, the back surface plays no part, and thickness is a plain distance.
innerSteps12Steps of the inner march that finds the exit surface, clamped to 1–40. A sphere ignores it: its exit is solved exactly.
chromaticAberration0Fraction of the refraction offset by which red and blue are read on either side of green.
roughness0Blur of the refracted image: 0–1 picks mip 0–5 of the background copy. Stored as a byte.
anisotropy0Smears the read along a direction — five taps weighted 1·4·6·4·1, spaced 0.015 × anisotropy in screen space — and raises the mip.
anisotropyRotation0The smear direction in radians; 0 is horizontal.
anisotropyBlur0Extra mip bias on the smear so it reads as a streak rather than five copies. Counts as blur even with anisotropy at 0.
distortion0Warps the read position with a noise field; full amplitude moves it by 0.05 of the screen.
distortionScale1Frequency of that noise, in world units.
temporalDistortion0Drifts the noise with scene time so the warp animates. Inert unless distortion is above 0.
OptionDefaultWhat it does
color#ffffffThe colour assumed behind pixels where the canvas is transparent — the page. The canvas is premultiplied, so a refracted read of an empty pixel is composited over this.
attenuationDistance1e6Beer–Lambert: light that travels this far through the glass arrives as attenuationColor. The default is clear.
attenuationColor#ffffffThe colour after attenuationDistance of travel. White is clear; the tint deepens with the path length through the volume.
OptionDefaultWhat it does
fresnel0.4Rim strength: (1 − N·V)^5 × fresnel mixes toward fresnelColor.
fresnelColor#ffffffRim colour. Black makes a shadow rim.
grain0Perturbs the surface normal with noise before the ray bends, 0–1.
grainScale300Grain frequency, 400 + 6 × grainScale. Higher is finer.
iridescence0Thin-film interference, 0–1.
iridescenceThickness400Film thickness in nanometres, ~100–800.
metalness0Mixes toward a mirror in attenuationColor, shaped by the ior-derived Fresnel. 1 is a mirror.
clearcoat0A polished top layer: a white Schlick rim with its own roughness, above metalness and below the fresnel rim.
clearcoatRoughness00 sharp rim, 1 broad halo.
sheen0A broad soft rim, (1 − N·V)², in sheenColor.
sheenColor#ffffff
outline0Darkens the silhouette to black, (1 − N·V)^8 × outline.
OptionDefaultWhat it does
reflection0Screen-space reflection of the shape pre-pass along the mirrored ray. Needs enableReflection on <Scene> — the flag multiplies the strength, so without it the option is inert. Mirrors other SDF shapes only, never particles, text or the mesh, and only a shape nearer than the glass surface: one behind or inside the glass refracts but does not reflect.
reflectionRoughness0Mip bias on that read, 0–5, from the shape mip chain.
gloss0A procedural studio environment — sky, ground, two bulbs — read along the reflected direction. Needs no scene flag.
glossSharpness0.7Bulb tightness, mapped to an exponent of 4–256.
glossCoverage0.18Schlick F0: 0 rim only, 1 the whole surface.
  • Modifiers, at a sphere’s exit. Glass takes modifiers like any shape and its surface march follows them, but under refraction: 'volume' a sphere’s exit is solved from its bare radius.
  • <Effect> outline and glow. Their slots hold attenuation and distortion on a glass shape; only the outline thickness survives, as envelope padding.
  • <Fast>. A glass shape inside <Fast> is counted as fast and drawn by the fast pipeline, which has no glass branch — it lights as lambert.

A glass <Mesh> takes the same set plus four silhouette options — see Mesh › MeshMaterial.

roughness, anisotropy, anisotropyBlur and reflectionRoughness each pull in a mip chain. Every other option is arithmetic in a shader already running.