# Lighting

Seven tuned light rigs, custom lights, lights that ride on nodes, and soft shadows.

Start from a rig and add lights only where you need them. Up to 8 lights in total, including the rig's.

```json title="apps/docs/examples/lighting.json"
{
  "camera": { "position": [0, 3, 8], "target": [0, 0.5, 0], "fov": 40 },
  "lighting": {
    "rig": "dramatic_noir",
    "rig_intensity": 0.4,
    "shadows": { "softness": 1.5, "strength": 0.8 },
    "lights": {
      "key": {
        "spot": {
          "position": [3, 5, 3],
          "target": [0, 0, 0],
          "angle": 30,
          "intensity": 120,
          "color": "#ffd8a8",
          "cast_shadows": true
        }
      },
      "rim": {
        "point": {
          "position": [-3, 2, -2],
          "intensity": 40,
          "color": "#4aa8ff"
        }
      }
    }
  },
  "environment": { "background": { "solid": "#0b0d12" } },
  "materials": { "floor": { "preset": "matte_clay", "color": "#2a2f3a" } },
  "nodes": {
    "floor": {
      "mesh": {
        "geometry": { "plane": { "size": [30, 30] } },
        "material": "floor"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "hero": {
      "transform": { "position": [0, 1, 0] },
      "mesh": {
        "geometry": { "torus_knot": { "radius": 0.8, "tube": 0.26 } },
        "material": "preset:brushed_metal"
      }
    }
  }
}
```

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

## Rigs

`studio_soft` (default), `three_point`, `dramatic_noir`, `golden_hour`, `neon_rim`, `high_key` and `moonlight`. `rig_intensity` scales the whole rig.

## Custom Lights

`lights` is a map of `ambient`, `directional`, `point` and `spot` lights. Spots aim at a `target` with a cone `angle` and soft `penumbra`. `cast_shadows` turns on shadows for directional and spot lights.

## Lights on Nodes

```json title="apps/docs/examples/node-lights.json"
{
  "camera": { "position": [6, 4, 8], "target": [0, 0.5, -4], "fov": 40 },
  "lighting": {
    "rig": "moonlight",
    "rig_intensity": 0.3,
    "lights": {
      "head_l": {
        "spot": {
          "parent": "truck",
          "position": [-0.6, 0.6, -2.1],
          "target": [-1, 0, -14],
          "angle": 22,
          "intensity": 80,
          "color": "#fff1d0"
        }
      },
      "head_r": {
        "spot": {
          "parent": "truck",
          "position": [0.6, 0.6, -2.1],
          "target": [1, 0, -14],
          "angle": 22,
          "intensity": 80,
          "color": "#fff1d0"
        }
      },
      "beacon": {
        "point": {
          "parent": "truck",
          "position": [0, 1.6, 0],
          "intensity": 12,
          "color": "#ffa31a",
          "range": 6
        }
      }
    }
  },
  "environment": {
    "background": { "solid": "#05070c" },
    "fog": { "density": 0.04, "scatter": 1, "color": "#10141c" }
  },
  "materials": {
    "road": { "color": "#1a1c20", "roughness": 0.5 },
    "paint": { "preset": "glossy_plastic", "color": "#e8a317" }
  },
  "nodes": {
    "road": {
      "mesh": {
        "geometry": { "plane": { "size": [12, 60] } },
        "material": "road"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "truck": {
      "transform": { "position": [0, 0.6, 0] },
      "mesh": {
        "geometry": { "box": { "size": [1.8, 1.2, 4] } },
        "material": "paint"
      }
    }
  },
  "timeline": {
    "duration": 4,
    "loop": "loop",
    "tracks": {
      "drive": {
        "target": "truck",
        "property": "position",
        "keyframes": [
          { "t": 0, "value": [0, 0.6, 4], "easing": "linear" },
          { "t": 4, "value": [0, 0.6, -6] }
        ]
      }
    }
  }
}
```

![Render of node-lights](/renders/node-lights.jpg)

Give a `point` or `spot` light a `parent` and its `position`, and a spot's `target`, are in that node's space. Headlights, beacons and torches then travel with the node. Nodes face -z.

```json
{ "spot": { "parent": "truck", "position": [0.9, 1.4, -4.4], "target": [1.8, 0, -26], "angle": 24, "intensity": 90 } }
```

To see the beams, add [fog](/docs/features/fog) with `scatter`.

## Shadows

`lighting.shadows` sets `softness` (PCF blur) and `strength`. `{"softness": 2, "strength": 0.6}` gives lighter, blurrier shadows.

Sun shadows use cascades on big scenes. `cascades` 1 fits one shadow map around everything, which is best for a single subject. 2 to 4 split the view into that many maps, so shadows stay crisp up close and still reach the far end of a street, city or landscape. The default 0 picks for you: cascades once the casters span more than about 50 units. `distance` caps how far from the camera they reach. The default 0 reaches the farthest caster.

```json title="scene.json"
{ "lighting": { "rig": "golden_hour", "shadows": { "cascades": 3, "distance": 120, "softness": 1.5 } } }
```

## API Reference

### Lighting

Scene lighting: start from a `rig` and add or override named `lights`.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `lights` | `map of Light` | `{}` | Extra lights keyed by id (patch-friendly: `/lighting/lights/<id>`). |
| `rig` | `LightRig` | `"studio_soft"` | Curated multi-light setup. Defaults to `studio_soft`; `null` for none (kept as `null` when serialized, so it doesn't revert to the default on a round trip). |
| `rig_intensity` | `number (0 to 10)` | `1` | Multiplier applied to every rig light. |
| `shadows` | `Shadows` | `{"softness":1,"strength":1}` | Shadow look for the shadow-casting light. |
### LightRig

Curated light setups tuned to look good with the material presets.

| Value | Description |
| --- | --- |
| `"studio_soft"` | Soft key + fill + rim; flattering product look (default). |
| `"three_point"` | Classic three-point lighting with crisp shadows. |
| `"dramatic_noir"` | Hard single key, deep shadows. |
| `"golden_hour"` | Warm low sun with cool sky fill. |
| `"neon_rim"` | Magenta/cyan rim lights for neon looks. |
| `"high_key"` | Bright, even, high-key lighting for slides and UI. |
| `"moonlight"` | Cool moonlight with a single warm accent. |
### Light

A single light. Written as `{"directional": {...}}`, `{"point": {...}}`, ...

- `{"ambient": { … }}`: Uniform fill light.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `Color` | `"#ffffff"` | Light colour. |
| `intensity` | `number` | `1` | Brightness. |

- `{"directional": { … }}`: Sun-like parallel light shining along `direction`.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `cast_shadows` | `boolean` | `false` | Whether this light casts shadows. |
| `color` | `Color` | `"#ffffff"` | Light colour. |
| `direction` | `[x, y, z]` | `[-0.4,-1,-0.6]` | Direction the light travels. |
| `intensity` | `number` | `1` | Brightness. |

- `{"point": { … }}`: Omni light at `position`.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `Color` | `"#ffffff"` | Light colour. |
| `intensity` | `number` | `1` | Brightness. |
| `parent` | `string` | — | Node the light rides on: `position` is then in that node's space and moves with it (headlights, beacons, a torch). |
| `position` (required) | `[x, y, z]` | — | Position in world space, or relative to `node` when it rides one. |
| `range` | `number` | `0` | Distance where the light fades out (0 = infinite). |

- `{"spot": { … }}`: Cone light at `position` aimed at `target`.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `angle` | `number` | `30` | Cone half-angle in degrees. |
| `cast_shadows` | `boolean` | `false` | Whether this light casts shadows. |
| `color` | `Color` | `"#ffffff"` | Light colour. |
| `intensity` | `number` | `1` | Brightness. |
| `parent` | `string` | — | Node the light rides on: `position` and `target` are then in that node's space and move with it. |
| `penumbra` | `number` | `0.5` | Edge softness 0..1. |
| `position` (required) | `[x, y, z]` | — | Position in world space, or relative to `node` when it rides one. |
| `target` | `[x, y, z]` | `[0,0,0]` | Point the spot aims at. |
### Shadows

Shadow softness and darkness.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `cascades` | `integer (0 to 4)` | — | Sun shadow detail over distance. 1 fits one map around everything (best for one subject); 2 to 4 split the view into that many cascades, crisp up close and still reaching the far end (streets, cities, landscapes). 0 picks: cascades once the casters span more than about 50 units. |
| `distance` | `number` | — | How far from the camera cascaded shadows reach, world units (0: to the farthest caster). |
| `softness` | `number (0 to 8)` | `1` | Blur radius multiplier (1 = default, 0 = hard, up to 8 = very soft; above 2.5 a denser, slower kernel is used). |
| `strength` | `number (0 to 1)` | `1` | How dark shadows get, 0..1 (1 = fully blocks the light). |
