Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage weather.package·originates fromworld 07158574-5…

weather

How surfaces respond to weather.

by◐lumi·posted 4mo ago
What it does

weather

How surfaces respond to weather.

local weather = require("@builtin::systems.weather.weather")

weather.set({ wetness = 0.8, snow = 0.0 })
weather.get()      --> the settings in force
weather.active()   --> is the pass running
weather.clear()    --> no weather, settings kept

set takes any subset. With both wetness and snow at 0 nothing is falling and the pass is released.

The first shelter field is ready when weather starts. Later changes to the renderable count rebuild its full-resolution replacement in the background. The pass and coverAt use the previous complete field until the replacement is ready. An explicit bakeShelter() updates the field before returning. Call bakeShelter(true) while the scene is dry to prepare the first field in the background before the rain arrives.

Three things decide what a surface gets: which way it faces, whether it is sheltered, and how much weather there is. shelter at 1 leaves anything under cover completely dry; at 0 the world is wetted evenly regardless of what is above it.

snowBias is how steeply a surface must face up before snow settles. Unlike rain, snow either lies or it does not, so it is a threshold rather than a ramp.

For weather a scene should simply have, author the Weather component instead. This module is for code driving weather over time — a storm cycle, a scripted downpour.

The full description is in the package readme: guides { path = "systems/weather" }.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module weather How surfaces respond to weather — wetness darkens and sharpens, snow settles on what faces up, and anything under cover stays clear. require systems/weather/weather

paramsBuffer( ) → any

The parameter buffer this system's passes read. A pass binds what this hands it, so it has the values this module packed.

examples

local b = weather.paramsBuffer()

coverBuffer( ) → any

The cover field the shelter test reads, as a buffer a pass binds.

examples

local b = weather.coverBuffer()

num(v: any, fallback: number) → number

argtypedescription
vany
fallbacknumber

rgb(v: any, fallback: { number }) → void

argtypedescription
vany
fallback{ number }

shelterRegion(v: any, fallback: { x: number, z: number, size: number }?) → void

The square of world a caller asked the cover field to cover. A call naming none keeps the one already in force; a `size` of 0 or less hands the extent back to the scene's own geometry.

argtypedescription
vany
fallback{ x: number, z: number, size: number }?

sameRegion(a: { x: number, z: number, size: number }?, b: { x: number, z: number, size: number }?) → boolean

argtypedescription
a{ x: number, z: number, size: number }?
b{ x: number, z: number, size: number }?

environmentRadiance( ) → void

The radiance the surroundings hand a reflection, spread over the whole hemisphere. A scene states that quantity as its ambient term — the same value `zpbr_environment_radiance` hands every PBR surface in it — so a wet sheen reflects it too, and a scene whose lights are out hands the sheen nothing.

sunLight( ) → void

The scene's directional light, as the pass reads it: the direction its light travels, its colour and its intensity. The film reflects it as a highlight rather than through the hemisphere term above, which is why it is packed on its own rather than folded into that radiance.

unchanged(values: { number }) → boolean

argtypedescription
values{ number }

ensureBuffers( ) → void

The buffers hang off the pass's own shader, so the feature picks them up by asking the same asset for them rather than through names that would have to agree across two files.

pushParams( ) → void

renderableCount( ) → number

How many renderables the last drawn frame put through its culling test, and how many copies the instanced draws the renderer draws place. The number moves when geometry is added or removed, which is the signal that a baked cover field no longer describes the scene.

geometryBox( ) → void

The box the scene's cover stands in, and the renderables that are no cover: the models that cast no shadow. The box spans the models that cast one and every entity that published a box for what it draws (a Generator, a Population). The cover field is baked over the box, so a point outside it has nothing above it by construction, and the bake's rays step over the models that are no cover.

measure(e: any) → void

argtypedescription
eany

bakeCover(background: boolean?) → ShelterField

Re-derive the cover field from the geometry the renderer draws: one ray up through each cell, recording the height of every underside it meets.

argtypedescription
backgroundboolean?

publish(payload: buffer, filled: number) → void

argtypedescription
payloadbuffer
fillednumber

syncCover( ) → void

Bake when there is no field yet, and re-bake when the scene's renderables have moved since the last one. The check itself is one call, and it is spaced out so a scene that is still loading does not bake on every frame.

set(opts: WeatherOpts?) → WeatherState

Set the scene's weather. Any omitted field keeps its current value, so a call can move one knob without restating the rest. With both `wetness` and `snow` at 0 nothing is falling and the pass is released.

argtypedescription
optsWeatherOpts?Weather settings — see `WeatherOpts`.

examples

weather.set({ wetness = 0.8, snow = 0 })

bakeShelter(background: boolean?) → ShelterField

Re-derive the cover field the shelter test reads from the geometry the renderer currently draws. The field is baked when weather starts and re-derived when the count of renderables moves; call this after moving or reshaping cover that left that count where it was.

argtypedescription
backgroundboolean?Optional. True prepares a replacement on workers and returns the current field.

examples

weather.bakeShelter()

shelterField( ) → ShelterField

Where the cover field the shelter test reads currently stands. A `resolution` of 0 means no field is baked, and every surface is then open to the sky.

examples

print(weather.shelterField().filled, "columns hold a surface")

coverAt(x: number, z: number) →

The undersides standing over a place in the cover field: the heights a column of the field recorded there, nearest the ground first. A place outside the field, or a field not baked, has none.

argtypedescription
xnumberWorld X of the place.
znumberWorld Z of the place.

examples

local roofs = weather.coverAt(0, 0)

get( ) → WeatherState

The weather currently in force.

examples

local w = weather.get().wetness

clear( ) → void

Clear the weather and release the pass. The other settings are kept, so a later `set` brings back the same look.

examples

weather.clear()

refresh( ) → void

Re-pack the buffer against the light the scene is standing in now — its ambient and its sun — and bring the cover field along with the scene. The pass runs every frame and the scene's lighting moves between frames, so the sheen follows the light rather than the value it had when the weather was last set. Writes only when something in the buffer has moved.

examples

weather.refresh()

active( ) → boolean

Whether the weather pass is currently running.

examples

if weather.active() then print("wet") end
⌬ Types
WeatherOpts = {ShelterField = {

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.