Skip to main content
Technical preview

Redraw is currently in technical preview, available to start-react-native.dev subscribers. API is unstable.

Materials

Materials are pre-built render functions that produce specific surface looks. Pass a material instance to brush.addFill(material) or brush.addStroke(material, width) and the renderer paints it.

Preview

The Materials API is evolving. Factories, options, and presets may change between versions. Pin a tag if you need stability.

This page covers all built-in material families. They live in packages/redraw/src/nodes/paints/.

PBR family

Physically-based rendering for cylindrical strokes and filled shapes. Cook-Torrance BRDF, Fresnel, GGX specular. The four variants share the same lights model: define lights once at the family-level shape:

const lights = {
directional: {
direction: [1.0, 2.0, 1.5],
color: [1.0, 1.0, 1.0],
intensity: 3.0,
},
ambient: {
color: [0.15, 0.15, 0.15],
intensity: 1.0,
},
};

Common options across the family:

OptionTypeWhat it controls
baseColor[r, g, b]Surface diffuse color (linear, 0–1).
roughnessf320 mirror, 1 fully diffuse.
metalnessf320 dielectric, 1 metal.
normalScalef32Cylinder normal extrusion intensity.
aoStrengthf32Curvature-based ambient occlusion.
emissive / emissiveIntensity[r,g,b] / f32Self-illumination.
lights{ directional, ambient }The lights setup above.
exposuref32Tone-mapping exposure.

createPBRMaterial

The base PBR for stroked tubes. Treats the stroke as a 3D cylinder and shades it with Cook-Torrance + Fresnel.

Cylindrical PBR with Fresnel + GGX specularOpen in editor →
Hello script with smooth ceramic PBR materialOpen in editor →

createPBRPillowMaterial

PBR for fills with a configurable inflated dome shape. Adds:

OptionTypeWhat it controls
heightf32Dome height above the surface.
curve"sqrt" | "smoothstep" | "linear" | "quadratic"Falloff shape from edge to peak.
maxDistancef32Distance over which the dome rises.

createPBRBevelMaterial

PBR with a chamfered edge for filled shapes. Adds:

OptionTypeWhat it controls
heightf32Bevel height. Negative values deboss.
bevelWidthf32Width of the bevel band before the flat top.

createPBRInnerFeatherMaterial

PBR with a soft feathered interior (sigma controls inward blur). Useful for soft buttons / debossed surfaces.

OptionTypeWhat it controls
heightf32Surface height.
sigmaf32Inward feather radius.

Stylized

createSoftVectorMaterial

iOS-style soft vector with inner shadow + specular highlight. No PBR machinery, just inner-edge falloff and a directional accent.

OptionTypeWhat it controls
baseColor[r, g, b] or [r, g, b, a]Body color.
innerShadowStrengthf32Edge darkness 0–1.
innerShadowRadiusf32Edge falloff distance.
innerShadowColor[r, g, b]Tint of the inner shadow.
highlightStrengthf32Specular brightness 0–1.
highlightPosition[x, y]Highlight direction.
highlightRadiusf32Highlight spread.
gradientDirection[x, y]Subtle body gradient direction.
gradientStrengthf32Body gradient depth.
edgeSoftnessf32AA-edge anti-alias band.

createNeumorphicMaterial

Multiple stacked inner shadows for the neumorphic look. Up to 4 shadows each with their own offset, blur, and color (MAX_NEUMORPHIC_SHADOWS = 4).

OptionTypeWhat it controls
baseColor[r, g, b]Body color.
innerShadowsNeumorphicInnerShadow[] (≤ 4)Each: { offset, blur, color }.
edgeSoftnessf32AA-edge band.
Climate-control dial: stacked inner shadows + gradient ring + soft highlightsOpen in editor →

createGlassMaterial

Refractive glass: warps a sampled backdrop using IOR and the reconstructed SDF gradient. Pseudo-3D thickness from a height field.

OptionTypeWhat it controls
sampleScalef32Backdrop tile-mode scaling.
offset[x, y]Backdrop offset for animated parallax.
tileModeTileModeHow the backdrop wraps.
thicknessf32Pseudo-thickness for refraction.
baseHeightf32Surface height.
iorf32Index of refraction (1.5 ≈ glass).
baseColor[r, g, b, a]Tint over the refracted backdrop.
colorMixf32Tint blend amount.
distortionScalef32Refraction strength.
edgeSoftnessf32AA-edge band.
strokeThicknessScalef32Stroke-mode thickness multiplier.

createHalftoneMaterial

Halftone dot patterns modulated by SDF lighting. Pop-art / Lichtenstein.

OptionTypeWhat it controls
dotColor[r, g, b]Dot color.
backgroundColor[r, g, b]Background color.
dotSpacingf32Distance between dot centers.
maxDotRadiusf32Largest dot.
minDotRadiusf32Smallest dot.
lightDirection[x, y]Light source for size modulation.
gridAnglef32Rotation of the dot grid.
style"dots" | "lines" | "diamonds"Pattern shape.
invertboolSwap dot/background.
dotSoftnessf32Per-dot edge softness.
GBA-style D-pad with pop art halftone dots, Lichtenstein inspiredOpen in editor →

Lighting

Lightweight 2D shading without the full PBR machinery.

Lit

Single-light Blinn-Phong on shape edges. Returns a render function; factory takes a config object:

import { Lit } from "redraw";

const material = Lit({
color: [0.8, 0.4, 0.2],
light: { dir: [1, -1, 1], color: [1, 1, 1], intensity: 1 },
ambient: 0.2,
diffuse: 0.7,
specular: 0.5,
shininess: 32,
});

LitDual

Two lights (key + fill) with independent direction, color, and intensity. Same shape config as Lit, with both light1 and light2.

Circle with two directional lights, white and orangeOpen in editor →

createStrokeEmbossMaterial

Edge-detect emboss restricted to the stroke region.

OptionTypeWhat it controls
baseColor[r, g, b]Surface color before emboss.
strokeWidthf32Width of the emboss band.
lightAnglef32Light direction (radians).
strengthf32Emboss intensity.

createFillEmbossMaterial

Emboss confined to the inner edge of a filled shape (visible up to maxDistance from the boundary).

OptionTypeWhat it controls
baseColor[r, g, b]Surface color.
maxDistancef32How far inward the emboss extends.
lightAnglef32Light direction (radians).
strengthf32Emboss intensity.

Picking a material

You wantReach for
3D-looking strokes (tubes, ribbons, calligraphy)createPBRMaterial
Filled shapes with depth (cushions, knobs)createPBRPillowMaterial
Sharp 3D bevelscreatePBRBevelMaterial
iOS-style soft buttonscreateSoftVectorMaterial
Neumorphism (soft UI)createNeumorphicMaterial
Frosted glass / refractioncreateGlassMaterial
Pop art / print lookcreateHalftoneMaterial
Cheap 2D shadingLit / LitDual
Edge emboss (engraved look)createStrokeEmbossMaterial / …Fill…