Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

README.md

surfaceWeather

The render feature behind Weather and @builtin::systems.weather.weather. One compute pass runs after lighting, at order 45.

What decides the response

Orientation. Rain and snow arrive from above, so an upward face collects both and a wall collects far less. Snow is the stricter of the two — it settles or it does not, so its orientation term is a threshold rather than a ramp.

Shelter. @builtin::systems.weather.weather bakes a cover field over the scene — an XZ grid whose columns hold the heights of the undersides standing over that place — and the pass reads the point's own column, blended across the four cells around it. Cover is a fact about the world, so a surface reads the same answer from every camera and every lens. Without this an overhang gets the same rain as open ground, which is the detail that gives away painted-on weather.

A point outside the grid is outside the geometry the field was baked over, so nothing stands above it.

Wetness

A water film has a higher index of refraction than air, so more light refracts into the surface and is absorbed, and what does reflect leaves in a tighter lobe. Both fall out of the same fact, so wetness darkens the surface and adds a sheen against water's 0.02 reflectance at normal incidence.

The sheen is a reflection, so it carries the light the surface stands in — taken the way the surface itself takes that light:

  • The surroundings, as one radiance over the whole hemisphere: the scene's ambient term, the quantity zpbr_environment_radiance hands every PBR surface, under skyColor's tint. It enters through the Schlick term at the viewing angle, which is what makes a wet floor brighten toward grazing.
  • The sun, from the scene's directional light, and every lamp the scene holds, out of @scene.lights — the same buffer the lit passes read. Each goes through the GGX/Smith/Schlick lobe those passes shade it with, at the film's own roughness, and on the terms its own kind is lit by: a point light through the windowed falloff that ends its reach, a spot through that and its cone, a rect from the face it emits along and against the part of it the film looks at, a distant light along its one direction everywhere. So a lamp's reflection in the water and the pool of light it lays on the floor agree about where that lamp is and how far it reaches.

A surface therefore answers the light in the room it stands in: warm under lamps, dark once the lights are out, and carrying the sun where the film happens to face it.

Snow

Settled snow takes over a surface's colour rather than tinting it. Its brightness is modulated by how lit the surface already was, so snow in a dim scene stays dim rather than glowing.

Camera

@frame.camera supplies the inverse view-projection; the forward matrix is inverted from it in the shader, which keeps offscreen captures and render-to-texture cameras correct.

Parameters arrive through the weather_params buffer, packed by @builtin::systems.weather.weather.