# Physical sky

> **Coming next.** This feature is not in `frost` yet. The page is written ahead so you can plan for it; until it ships, nothing here works in the `frost` you have.


A sky worked out from a real atmosphere, with clouds, a moon and stars, that you turn on
with one field. The engine's `Sky` today is a painted day: the hour picks the sun, the sky's colours and
the ambient light. The physical sky works them out from an atmosphere instead: the
scattering of air, haze and ozone over a round Earth, twilight, a sun and a moon with
phases, stars, two sheets of cloud with their shadows, and light and reflections from
that same sky, on every backend. A game opts in; a game that does not keeps its picture
and its checksums.

## Opting in

One field of `Sky` turns it on: `model = "physical"`, or a named `look`, or a `picture`.

| Write | Gives |
| --- | --- |
| `Sky = { model = "physical", time = 17.75 }` | The clear preset at a quarter to six |
| `Sky = { look = "desert", time = 17.75 }` | Dust in the air, pale ground |
| `Sky = { look = "alpine", time = 9 }` | Thin clear air, morning |
| `look = "overcast"`, `look = "storm"` | Heavy cloud |
| `Sky = { picture = "art/sky.png" }` | An equirectangular PNG as the sky, lighting and reflections from it |

`time`, `turn`, `shadows` and `reach` mean what they mean today. Shadows follow the sun;
moonlight casts none.

## Tuning a look

Each preset can be changed a field at a time; a field left at -1 keeps the preset's:

| Field | Range | Is |
| --- | --- | --- |
| `turbidity` | 1 to 10 | How much haze and dust the air holds |
| `albedo` | 0 to 0.95 | How much light the ground gives back |
| `tint` | sRGB | A tint of the atmosphere and clouds |
| `altitude` | metres | The ground's height above the sea |
| `cloud_coverage`, `cloud_density`, `cloud_height` | 0 to 1, 0 to 4, metres | The low sheet of cumulus |
| `cirrus_coverage`, `cirrus_density`, `cirrus_height` | 0 to 1, 0 to 4, metres | The high sheet of cirrus |
| `wind_x`, `wind_z` | metres a second | How the clouds drift |
| `moon_phase` | 0 to 1 | 0 new, 0.5 full |
| `seed` | whole number | Which stars |

With a physical sky the haze becomes the atmosphere's own: distant things take its
colour by distance (`haze_far` sets how far it is sampled). The sun's disc stays bright
enough to bloom. Clouds are for views from the ground; flying into or above them is not
supported.

## Cost and determinism

The atmosphere's tables are worked out on the CPU with portable arithmetic, so every
machine makes the same sky. A small change of the sun reuses them; a larger one rebuilds
them in fixed slices, one a step, and cross-fades over 30 steps, so time of day can move
every step without a hitch. A still capture settles the sky first, so a shot is the same
picture whatever came before it. Wind and twinkling stars move with the step, so a held
frame is held.

`frame.at` names the sky's light, the moon's, the light through clouds and the
atmosphere's haze in its account of a pixel.

When it ships, it gets a sample of its own and a section in the
[3D rendering guide](../guides/3d-rendering.md).
