sky.package
This package holds more than this page lists. See all of its files in its world.
README.md
skyLight
The light the scene takes from what is drawn behind it. It captures that
picture into a cube of six textures it owns, gathers the cube into a diffuse
term and a set of reflection bands, and adds both to every lit surface in a
pass of its own, at the strengths its parameters state. Whatever draws the
backdrop (a gradient, a material, a photograph, clouds) is what it captures:
the capture is a render of the captureLayers, with no knowledge of what draws
them.
Every step is a call in its init.luau:
- Capture. Six cameras, one per cube face, each 90 degrees across, stand at
capturePositiondrawing onlycaptureLayersand running only the render-feature passescaptureFeaturesnames: by default the ones an environment capture runs, so a fog or a volumetric medium filling the air stays out of the light that lights it. Each is held disabled and rendered once into afaceSizexfaceSizetexture. - Gather.
skyLight_facesfolds the six faces into one equirectangular map, whichibl_irradianceconvolves into the diffuse term andibl_specularinto five reflection bands of rising roughness. These run on the frames after a capture. - Light. Every frame
skyLight_applyadds both terms to the lit G-buffer, the diffuse term scaled bydiffuseand the reflection byreflection. - Publish. With
publishReflectionon,environment.captureSkyputs the sky, drawn fromcapturePosition, into the environment's sky slot: the reflection every surface the reflection probes leave uncovered shows, water and transparent surfaces among them, which the G-buffer pass never reaches. Turned off, or with the feature torn down, the slot is switched off.
A capture is taken when the feature is set up, when what it draws changes
(captureLayers, captureFeatures, capturePosition, faceSize, or
recapture, a count an author changes to ask for one), and, with followSky
on, when the scene's sky row or the direction of its sun changes, at most once per recaptureInterval
seconds. The diffuse term and the reflection bands are gathered from every
capture whatever the strengths, so a strength changed relights from them.
What a render feature draws into the capture (an atmosphere's sky, a layer
over the sky) is part of the picture. A capture, and the sky slot the sky light
publishes, is taken once every live render feature has drawn with the settings
it holds, so a setup applied in one step is captured as it stands once all its
members are in force; the wait ends after 120 drawn frames at most. With
followSky on, a change of value in the settings of a render feature that runs
in environment captures (its contentRevision in renderer.feature.list)
takes a capture and, with publishReflection on, publishes the sky into the
slot again, at most once per recaptureInterval seconds. The sky light's own
settings do not count.
A render drawn while the renderer still held builds for the scene (pipelines,
shader compiles; the pipelinesPending of the face camera's lastRender in
camera.observe()) holds the scene as it looked before they landed. The six
faces are rendered again, at growing intervals of drawn frames, until one is
drawn with nothing pending; redraws counts those repeats.
Parameters
| name | default | what it is |
|---|---|---|
diffuse | 0.15 | The strength of the captured surroundings' diffuse light on surfaces, 0 to 4. |
reflection | 0.25 | The strength of the captured surroundings in surfaces' reflections, 0 to 4. |
captureLayers | sky | The render layers the capture draws. |
captureFeatures | environment | Which render-feature passes the capture runs: environment, the ones an environment capture runs (the sky and what is drawn into it; the air and overlays stay out), or all. |
capturePosition | (0, 0, 0) | Where the six capture views are taken from. |
faceSize | 64 | The width and height of each capture view, in texels. |
followSky | true | Whether a change to the sky row, the sun's direction or the settings of a render feature that runs in environment captures takes a capture. |
recaptureInterval | 0.5 | The fewest seconds between two captures followSky takes. |
recapture | 0 | A count; any change takes a capture. |
publishReflection | false | Whether the sky also fills the environment's sky slot, the reflection a surface no reflection probe covers shows. |
occlusionSource | empty | The member whose picture of how much of the sky each surface sees (live.skyVisibility) scales the diffuse and reflection terms, as its identity; empty, the terms are not scaled. |
With both strengths at 0 it enqueues no lighting pass and still gathers the
captured environment, which other members read. The textures it captured
into and gathered (faces, environment, irradiance, reflection), the
number of captures taken (captures), of repeated renders (redraws) and of
gathers that have written the irradiance and reflection maps (gatherCount)
are readable at
modules.state("@builtin::systems.sky.skyLight.live").
# a setup member
- id: skyLight
source: "@builtin::systems.sky.skyLight"
values:
diffuse: 0.15
reflection: 0.25