# Materials

Physically based materials with 16 presets, flat and toon shading, outlines and procedural surfaces.

Declare materials once in `materials` and refer to them by id from a mesh or text. Or use a preset inline with `"material": "preset:chrome"`.

```json title="apps/docs/examples/materials.json"
{
  "camera": { "position": [0, 0, 9], "target": [0, 0, 0], "fov": 40 },
  "lighting": { "rig": "studio_soft" },
  "environment": {
    "background": { "solid": "#20242c" },
    "reflections": "studio"
  },
  "post": { "bloom": 0.6 },
  "nodes": {
    "matte_clay": {
      "transform": { "position": [-3.75, 0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:matte_clay"
      }
    },
    "glossy_plastic": {
      "transform": { "position": [-2.25, 0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:glossy_plastic"
      }
    },
    "chrome": {
      "transform": { "position": [-0.75, 0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:chrome"
      }
    },
    "brushed_metal": {
      "transform": { "position": [0.75, 0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:brushed_metal"
      }
    },
    "gold": {
      "transform": { "position": [2.25, 0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:gold"
      }
    },
    "glass": {
      "transform": { "position": [3.75, 0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:glass"
      }
    },
    "frosted_glass": {
      "transform": { "position": [-3.75, -0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:frosted_glass"
      }
    },
    "ceramic": {
      "transform": { "position": [-2.25, -0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:ceramic"
      }
    },
    "velvet": {
      "transform": { "position": [-0.75, -0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:velvet"
      }
    },
    "neon": {
      "transform": { "position": [0.75, -0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:neon"
      }
    },
    "holographic": {
      "transform": { "position": [2.25, -0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:holographic"
      }
    },
    "toon": {
      "transform": { "position": [3.75, -0.8, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "preset:toon"
      }
    }
  }
}
```

![Render of materials](/renders/materials.jpg)

## Presets

A preset sets sensible values; any field you write overrides it.

`matte_clay`, `glossy_plastic`, `chrome`, `brushed_metal`, `gold`, `glass`, `frosted_glass`, `ceramic`, `velvet`, `neon`, `holographic`, `toon`, and the surface presets `gravel`, `rock`, `weathered_paint` and `stucco`.

```json
{ "materials": { "glow": { "preset": "neon", "color": "#ff2ec4", "emissive_intensity": 5 } } }
```

## Glow

`emissive` and `emissive_intensity` make a material give off light. Above about 1, [bloom](/docs/features/post) picks it up. Neon tubes look best at `emissive_intensity` 4 or more with `bloom_radius` 0.6 to 0.8.

## Stylised Shading

```json title="apps/docs/examples/shading.json"
{
  "camera": { "position": [0, 1.5, 7], "target": [0, 0.3, 0], "fov": 40 },
  "lighting": {
    "rig": "golden_hour",
    "shadows": { "softness": 2, "strength": 0.6 }
  },
  "environment": { "background": { "solid": "#9fc6e8" } },
  "materials": {
    "flat": { "color": "#e07a5f", "shading": "flat" },
    "toon": {
      "color": "#3d85c6",
      "shading": "toon",
      "bands": 3,
      "outline": { "color": "#111111", "width": 0.04 }
    },
    "ground": { "color": "#81b29a", "shading": "flat" }
  },
  "nodes": {
    "ground": {
      "mesh": {
        "geometry": { "plane": { "size": [20, 20] } },
        "material": "ground"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "rock": {
      "transform": { "position": [-1.4, 0.8, 0] },
      "mesh": {
        "geometry": { "icosahedron": { "radius": 0.9 } },
        "material": "flat"
      }
    },
    "blob": {
      "transform": { "position": [1.4, 1.1, 0], "rotation": [0, 0, 20] },
      "mesh": {
        "geometry": { "capsule": { "radius": 0.55, "length": 0.7 } },
        "material": "toon"
      }
    }
  }
}
```

![Render of shading](/renders/shading.jpg)

- `"shading": "flat"`: faceted, matte, low-poly.
- `"shading": "toon"` with `"bands": 3`: cel shading.
- `"outline": {"color": "#111", "width": 0.04}`: an inverted-hull silhouette in world units. It suits convex shapes. On tightly wound shapes like a torus knot the hull covers the mesh.
- `unlit: true` ignores lights entirely.

To recreate the washed-out look of older three.js demos, pair `flat` shading with `post.color_management: "legacy"` and `tone_mapping: "none"`.

## Surfaces

```json title="apps/docs/examples/surfaces.json"
{
  "camera": { "position": [0, 1.2, 6], "target": [0, 0.6, 0], "fov": 40 },
  "lighting": { "rig": "golden_hour" },
  "environment": { "background": { "sky": {} } },
  "materials": {
    "gravel": { "preset": "gravel" },
    "rock": { "preset": "rock" },
    "paint": { "preset": "weathered_paint", "color": "#3d7ea6" },
    "stucco": { "preset": "stucco" }
  },
  "nodes": {
    "ground": {
      "mesh": {
        "geometry": { "plane": { "size": [30, 30] } },
        "material": "gravel"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "boulder": {
      "transform": { "position": [-2.1, 0.7, 0] },
      "mesh": {
        "geometry": { "icosahedron": { "radius": 0.8 } },
        "material": "rock"
      }
    },
    "drum": {
      "transform": { "position": [0, 0.7, 0] },
      "mesh": {
        "geometry": { "cylinder": { "radius": 0.5, "height": 1.4 } },
        "material": "paint"
      }
    },
    "wall": {
      "transform": { "position": [2.1, 0.7, 0], "rotation": [0, -20, 0] },
      "mesh": {
        "geometry": { "box": { "size": [1.4, 1.4, 0.4] } },
        "material": "stucco"
      }
    }
  }
}
```

![Render of surfaces](/renders/surfaces.jpg)

`surface` adds procedural colour, roughness and bump on top of any material. Patterns are `noise` (dirt, stains), `gravel`, `rock` (strata), `rust` (rust eating through paint, where `color` is the rust) and `stucco`. `scale` is the feature size in world units. Patterns are solid 3D noise, so there are no UVs or seams, and they fade with distance.

```json
{ "surface": { "pattern": "gravel", "color": "#5a3c50", "scale": 0.1, "contrast": 0.6, "bump": 0.8 } }
```

For images on materials see [Textures](/docs/features/textures). For water see [Water](/docs/features/water).

## Blending

`blend: "add"` makes a surface add light to whatever it covers instead of covering it: glows, flames, light shafts and sparks brighten and never darken. It draws as a transparent surface (no depth write), so it doesn't hide what's behind it.

## API Reference

### Material

A physically based material. Start from a `preset` and override any field.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `bands` | `integer (2 to 8)` | — | Number of light bands for `toon` shading (2-8, default 3). |
| `blend` | `Blend` | — | How the surface combines with what is behind it: `normal` (default) or `add` (light: glows, flames, shafts and sparks brighten what they cover and never darken it). |
| `clearcoat` | `number (0 to 1)` | — | Clear lacquer layer strength, 0..1. |
| `color` | `Color` | — | Base color (albedo). |
| `emissive` | `Color` | — | Emitted light color (glows with bloom). |
| `emissive_intensity` | `number (0 to 100)` | — | Emission strength multiplier. |
| `emissive_map` | `TextureMap` | — | Image multiplied into `emissive` (signs, screens, lit windows). Set `emissive` (white is fine) for it to glow. |
| `ior` | `number (1 to 3)` | — | Index of refraction used with transmission. |
| `iridescence` | `number (0 to 1)` | — | Thin-film iridescence strength, 0..1 (holographic looks). |
| `map` | `TextureMap` | — | Image multiplied into `color` (sRGB; its alpha multiplies opacity). Mapped with the geometry's UVs. |
| `metalness` | `number (0 to 1)` | — | 0 = dielectric, 1 = metal. |
| `opacity` | `number (0 to 1)` | — | Overall opacity, 0..1. |
| `outline` | `Outline` | — | Draw a solid silhouette outline around meshes using this material. |
| `preset` | `MaterialPreset` | — | Starting point; every other field overrides the preset value. |
| `roughness` | `number (0 to 1)` | — | 0 = mirror, 1 = fully diffuse. |
| `shading` | `Shading` | — | Lighting model: `pbr` (default), `flat` (faceted matte, like three.js flatShading) or `toon` (banded matte). |
| `surface` | `Surface` | — | Procedural surface detail: noise-driven colour, roughness and bump (gravel, rock, rust, stucco). Solid 3D noise, so no UVs or seams. |
| `transmission` | `number (0 to 1)` | — | Glass-like light transmission, 0..1. |
| `unlit` | `boolean` | — | Unlit/flat shading (ignores lights). |
| `water` | `Water` | — | Water: moving waves and a mirror reflection of the scene above it. Put it on a flat, horizontal plane (one water level per scene); `color` is the deep water colour. |
| `wireframe` | `boolean` | — | Render as wireframe. |
### MaterialPreset

Curated, tuned material looks.

| Value | Description |
| --- | --- |
| `"matte_clay"` |  |
| `"glossy_plastic"` |  |
| `"chrome"` |  |
| `"brushed_metal"` |  |
| `"gold"` |  |
| `"glass"` |  |
| `"frosted_glass"` |  |
| `"ceramic"` |  |
| `"velvet"` |  |
| `"neon"` |  |
| `"holographic"` |  |
| `"toon"` |  |
| `"gravel"` |  |
| `"rock"` |  |
| `"weathered_paint"` |  |
| `"stucco"` |  |
### Shading

How a material responds to light.

| Value | Description |
| --- | --- |
| `"pbr"` | Physically based (metalness/roughness, reflections). |
| `"flat"` | Matte, one normal per face: low-poly, faceted look. |
| `"toon"` | Matte with hard light bands (cel shading). |
### Outline

A silhouette outline (inverted hull), in world units.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `Color` | `"#1a1a1a"` | Outline colour. |
| `width` | `number (0 to 1)` | `0.03` | Thickness in world units. |
### Surface

Procedural surface detail on top of a PBR material. `color` is the second colour the pattern mixes in (stones, rust, stains).

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `bump` | `number (0 to 2)` | `0.5` | Bump strength, 0..2. |
| `color` | `Color` | — | Second colour (defaults to a darker, warmer take on the base colour). |
| `contrast` | `number (0 to 1)` | `0.5` | How sharply the two colours separate, 0..1. |
| `pattern` (required) | `SurfacePattern` | — | The procedural pattern: gravel, rock, rust, stucco and more. |
| `roughness_variation` | `number (0 to 1)` | `0.3` | How much roughness varies with the pattern, 0..1. |
| `scale` | `number (0.001 to 1000)` | — | Feature size in world units (default per pattern). |
| `seed` | `integer` | `0` | Seed for the pattern's noise. |
### SurfacePattern

Built-in procedural patterns.

| Value | Description |
| --- | --- |
| `"noise"` | Soft fbm blotches: dirt, stains, sand. |
| `"gravel"` | Packed pebbles with dark gaps (voronoi): gravel lots, desert floor. |
| `"rock"` | Layered, ridged stone with strata: cliffs, boulders. |
| `"rust"` | Rust patches and streaks eating through paint: weathered metal. |
| `"stucco"` | Fine bumpy plaster: walls. |
### Blend

Blend mode of a material.

| Value | Description |
| --- | --- |
| `"normal"` |  |
| `"add"` |  |
