Weather
A scene’s weather is not a pile of effect parameters. A project’s fog is in its own units and its sun is as bright as its author made it, so a weather is expressed as multipliers of what the scene already says — the sun at a quarter of its strength, the fog five times as thick, the picture a little greyer — plus a few levels that mean the same everywhere: how hard it rains, how wet the ground is. The same preset then fits any project.
The component
Section titled “The component”Add a Weather component to one entity.
| Field | What it does |
|---|---|
preset |
The weather the scene is in: Clear, Mist, Overcast, Rain, Storm. |
target |
The weather it is turning into; None for none. |
progress |
How far along that turn it is (0–1). The game advances it; set it in the editor to preview a half-turn. |
duration |
Seconds a turn takes. |
sequence |
Presets to cycle through by themselves, comma separated — clear,mist,rain,clear. Empty stays put. |
hold |
Seconds each weather of the sequence holds before the next turn. |
drive |
What the weather drives: Lights, Fog, Rain, Grade, Exposure, Reflections, Sound. |
soundSource |
An entity with a looping AudioSource — the sound of the rain. The weather raises its playing while it rains and sets its volume to the authored one times how hard it rains. |
A turn is eased, so it starts and ends gently, and a finished turn lands on its target and clears itself.
In the editor
Section titled “In the editor”The Details panel shows the five built-in weathers as buttons (a project’s own preset id still works and shows as Custom), the move toward the next one as a progress you can drag, the cycle and what the weather drives, and a readout of what it is doing to the picture right now — the key light’s scale, the fog’s, the wetness and the rain. Rain and fog reach the picture through a Post Process Volume, which the panel says.
What a weather changes
Section titled “What a weather changes”- Lights. Directional lights are scaled (and tinted) and the ambient light is scaled, from the strengths they were
authored with — the weather scales your number, never its own last answer — and they are put back when the weather
is taken away or
Lightsis switched off. Only while the game runs: in the editor the lights are left alone, so previewing a weather never changes the scene you save. - Shadows. The directional light’s shadows get softer (a source
shadowSoftnesssuns wide) and lighter (shadowStrengthtimes the authored darkness) as the sky clouds over, the way an overcast sky’s shadows fade into the ground. - Fog. Height Fog’s density, its sun glow and the volumetric light it carries are scaled, its sky haze is raised, and its colour moves toward the weather’s.
- Rain. The Rain effect is brought with the weather (when the scene has none) at the preset’s strength, and Rain and Screen Space Reflections are given the wetness and puddles it leaves. Where the scene authored its own rain, the weather can only raise it.
- Reflections. A baked reflection probe shows the sky it was baked under, so a rainy street would mirror a sunny one.
The ambient light carries
reflectionScaleandreflectionSaturationfor exactly this: what baked probes show is multiplied by the first and drained of colour by the second, and the weather turns both down. - Sky. A Sky Atmosphere effect takes the preset’s
overcastas cloud coverage and haze: the clouds thicken and join up, and the sun, moon and stars behind them are hidden by the same transmittance. - Grade and exposure. Colour Grade’s saturation and contrast are scaled, and Auto Exposure’s compensation raised.
The effects are applied after the scene’s volumes have blended, so a scene that fogs itself thinly stays thinner than one that fogs itself thickly in the same rain.
Your own weathers
Section titled “Your own weathers”import { registerWeatherPreset, WEATHER_CLEAR } from 'esengine';
// A preset names only what it changes; everything else is neutral.const sandstorm = registerWeatherPreset('sandstorm', { sun: 0.5, fogDensity: 10, fogTint: [0.82, 0.62, 0.38], fogTintAmount: 0.85, saturation: 0.8, exposure: 0.4,});A custom preset answers to its name in a sequence, and to the id registerWeatherPreset returns in preset and
target. Registering a built-in name again retunes it.
Turning by code
Section titled “Turning by code”The component is data: write target and progress: 0 and the system does the rest.
world.insert(weatherEntity, Weather, { target: WEATHER_RAIN, progress: 0, duration: 10 });