# Sky and Environment

Backgrounds, a procedural sky with sun, clouds, haze and horizon glow, and reflections.

`environment.background` is what's behind the scene: a solid colour, a linear or radial gradient, `transparent` for web embeds, or a procedural `sky`.

```json title="apps/docs/examples/sky.json"
{
  "camera": { "position": [0, 1.5, 8], "target": [0, 2, -10], "fov": 60 },
  "lighting": { "rig": "golden_hour" },
  "environment": {
    "background": {
      "sky": {
        "sun": { "azimuth": -10, "elevation": 4 },
        "clouds": { "coverage": 0.5 },
        "glow": {
          "color": "#ff8a3d",
          "intensity": 1.4,
          "azimuth": 40,
          "width": 90,
          "height": 6
        }
      }
    }
  },
  "post": { "bloom": 0.6, "tone_mapping": "agx" },
  "materials": { "ground": { "color": "#3b2c3a", "roughness": 0.9 } },
  "nodes": {
    "ground": {
      "mesh": {
        "geometry": { "plane": { "size": [400, 400] } },
        "material": "ground"
      },
      "transform": { "rotation": [-90, 0, 0] }
    }
  },
  "timeline": { "duration": 4, "loop": "loop" }
}
```

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

## Sky

`{"sky": {}}` alone is a golden-hour sky. Then adjust:

- `zenith`, `horizon` and `ground`: the gradient.
- `sun`: `azimuth` (degrees clockwise from -z, the default view direction), `elevation`, `size`, `intensity` and `glow`. `"sun": null` turns it off.
- `clouds`: `coverage`, `layers`, `scale`, `speed`, and the warm `underlight` and `shade` colours. Clouds drift with `speed` and are seeded by the scene `seed`. `"clouds": null` turns them off.
- `haze`: horizon haze.
- `glow`: a light hugging the horizon, like a distant city or fire. `width` is degrees round the horizon (360 all the way) and `height` how high it climbs. It's HDR, so bloom and mist carry it.

## Reflections

`environment.reflections` picks the environment that shiny materials reflect: `studio` (default), `sunset`, `city`, `night` or `none`.

## API Reference

### Environment

Background, fog and image-based lighting.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `background` | `Background` | `{"solid":"#0b0f1a"}` | What's behind the scene: a colour, a gradient, a procedural sky or transparent. |
| `fog` | `Fog` | — | Distance fog, which can also scatter light into visible beams. |
| `reflections` | `EnvironmentMap` | `"studio"` | Built-in environment map for reflections. |
### Background

Scene background. `{"solid": "#000"}`, `{"linear_gradient": {...}}`, ...

| Value | Description |
| --- | --- |
| `"transparent"` | Fully transparent (for web embeds and overlays). |

- `{"solid": Color}`: A flat colour.

- `{"linear_gradient": { … }}`: Vertical-ish gradient from `from` to `to`, rotated by `angle` degrees.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `angle` | `number` | `0` | Rotation of the gradient in degrees. |
| `from` (required) | `Color` | — | Colour at the start of the gradient. |
| `to` (required) | `Color` | — | Colour at the end of the gradient. |

- `{"radial_gradient": { … }}`: Radial gradient from the center (`inner`) to the edges (`outer`).

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `inner` (required) | `Color` | — | Colour at the centre. |
| `outer` (required) | `Color` | — | Colour at the edges. |

- `{"sky": Sky}`: Procedural sky dome seen through the camera: gradient, sun disc, sunset scattering, layered clouds and horizon haze.
### Sky

Procedural sky. Every field has a sunset-friendly default, so `{"sky": {}}` is a valid golden-hour sky.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `clouds` | `Clouds` | `{"color":"#ffe6d2","coverage":0.45,"layers":2,"scale":1,"shade":"#7a5a8a","speed":0.02,"underlight":"#ff8a4c"}` | Layered procedural clouds. `null` for a clear sky. |
| `glow` | `HorizonGlow` | — | A glowing band on the horizon: a city's light dome, a distant fire. |
| `ground` | `Color` | `"#3b2c3a"` | Colour below the horizon. |
| `haze` | `number (0 to 1)` | `0.4` | Horizon haze, 0..1: a bright band that also softens the clouds. |
| `horizon` | `Color` | `"#ff9e6b"` | Colour at the horizon. |
| `sun` | `Sun` | `{"azimuth":0,"color":"#ffd28a","elevation":6,"glow":0.8,"intensity":6,"size":2.5}` | Sun disc and the warm scattering around it. `null` for no sun. |
| `zenith` | `Color` | `"#3a3d8f"` | Colour straight up. |
### Sun

The sun on the sky dome.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `azimuth` | `number` | `0` | Degrees clockwise from straight ahead (-z, the default view direction): 90 is +x, 180 is behind the camera. |
| `color` | `Color` | `"#ffd28a"` | Colour of the disc and its glow. |
| `elevation` | `number (-90 to 90)` | `6` | Degrees above the horizon (negative sets it below). |
| `glow` | `number (0 to 2)` | `0.8` | Strength of the warm glow scattered around the sun, 0..2. |
| `intensity` | `number (0 to 50)` | `6` | HDR brightness of the disc (bloom picks it up above ~1). |
| `size` | `number (0 to 20)` | `2.5` | Disc diameter in degrees. |
### Clouds

Procedural cloud layers, seeded by the scene seed.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `Color` | `"#ffe6d2"` | Lit cloud tops. |
| `coverage` | `number (0 to 1)` | `0.45` | Fraction of the sky covered, 0..1. |
| `layers` | `integer (1 to 3)` | `2` | Number of layers, 1..3 (higher layers are thinner and wispier). |
| `scale` | `number (0.1 to 10)` | `1` | Feature size: larger is smaller, busier clouds. |
| `shade` | `Color` | `"#7a5a8a"` | Cloud undersides away from the sun. |
| `speed` | `number (0 to 2)` | `0.02` | Drift speed (sky units per second). |
| `underlight` | `Color` | `"#ff8a4c"` | Warm light on the undersides near a low sun. |
### HorizonGlow

Emissive light hugging the horizon, brightest at `azimuth`.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `azimuth` | `number` | `0` | Degrees clockwise from -z where the glow is centred (like the sun's). |
| `color` | `Color` | `"#ff9a4a"` | Colour of the glow. |
| `height` | `number (0.5 to 60)` | `8` | How high it climbs, in degrees. |
| `intensity` | `number (0 to 50)` | `1.5` | Brightness; above about 1 it blooms. |
| `width` | `number (1 to 360)` | `120` | How far round the horizon it spreads, in degrees (360: all the way). |
### EnvironmentMap

Built-in environment maps (no external assets, fully deterministic).

| Value | Description |
| --- | --- |
| `"none"` |  |
| `"studio"` |  |
| `"sunset"` |  |
| `"city"` |  |
| `"night"` |  |
