Builtin Library
- ..
- .metadata590 B
- README.md5.1 KB
- sceneSetup.yaml2.2 KB
README.md
dynamicLighting
A scene setup that lights a scene with the engine's real-time lighting in one placement: a sky whose hour drives a sun and a moon, the sky's light, ray-traced probe global illumination, ambient occlusion, contact shadows, height fog, exposure that adapts between day and night, temporal anti-aliasing and screen-space reflections. Every light the scene receives comes from a member listed here, with the values it is placed at, so each contribution is a row of the placement's card that an author reads and edits.
Placing it
Drag it into the viewport, or place it from a scene's build.luau:
asset.resolve("@builtin::systems.sceneLighting.dynamicLighting", "sceneSetup")
:instantiate(nil, { name = "lighting" })
A scene that already places a setup takes this one by naming it on its
lighting line, or by pointing the lighting entity's Asset source at it.
Selecting lighting shows every member and every value below; an edit there is
that scene's own override. A scene that holds Light entities of its own for
the sun or the ambient term keeps them beside the setup's and ties with its sun,
so the setup lights a scene alone once those entities are removed.
Day and night
The sky's hour, sky/backdrop/timeOfDay, is the one value that moves a scene
between day and night. The sun and the moon follow the sky, the backdrop draws
its night colours, stars and moon once the sun is below the horizon, the sky
light captures what it draws, the probe field carries that light, and the
exposure follows the frame. At 16:00 the sun stands 30° up; at 22:00 the moon
lights the scene and the scene's own lamps carry the rest.
Members
| id | source | what it puts on the scene |
|---|---|---|
sky | ./dynamicSky.sky | The procedural backdrop at 16:00, a clear blue day over a grey-green ground, with dark blue-black night colours, stars and a moon. |
sun | ./dynamicSun.sceneLight | A shadow-casting directional light that follows the sky: a warm white at 4 from 30° up, dimmer and warmer toward the horizon, out after dark. |
moon | ./dynamicMoon.sceneLight | A shadow-casting distant light that follows the sky and keeps its 0.05: after dark it stands at the moon the sky draws and lights the scene a cool blue-white, an eightieth of the sun, which the exposure's 2 stops lift to a dark moonlit night. While the sun is up it stands with the sun and adds its 0.05 to the sun's 4. |
skyLight | @builtin::systems.sky.skyLight | Captures the drawn sky. diffuse 0, because the probe field carries the sky's diffuse light; reflection 0.5, the sky every surface reflects, scaled by how much of the sky the field finds each surface sees (occlusionSource). |
gi | @builtin::systems.probeGI.probeGI | Ray-traced probe global illumination: three cascades of 16 x 8 x 16 probes, the finest 1.5 m apart, 48 rays a probe, its updates held to 1 ms of GPU time a frame (updateBudgetMs), each probe aiming rays at up to 4 small emitters near it (aimedEmitters). Its rays return the sky light's capture (skySource) where they leave the scene, and at a surface the sun's, the moon's, every lamp's and every emissive surface's light, so the bounce of each reaches the rooms and the shade. |
ao | @builtin::systems.ambientOcclusion.ambientOcclusion | Screen-space ambient occlusion with a 0.6 m radius, under half of the field's finest spacing, so the field and the occlusion each darken their own scale of contact. The field takes it through its contactOcclusion of 1. |
contactShadows | @builtin::systems.contactShadows.contactShadows | Short screen-space shadows (0.35 m) where the sun's shadow map is too coarse: under feet, legs and the edges of things standing on a floor. They follow the sun. |
fog | @builtin::systems.atmosphere.heightFog | A thin haze, 0.004 per metre at the ground thinning with height, lit by the sun and by the sky light's capture, so distance reads by day and the night air stays dark. Its colour, (0.92, 0.95, 1.0), meets the horizon of the drawn sky. |
exposure | @builtin::systems.exposure.exposure | Automatic exposure metering the centre of the frame at photographic middle grey. It may open the picture by up to 2 stops (maxEV), so a sunlit room reads and a night stays dark, and close it by up to 4 (minEV). |
taa | @builtin::systems.antiAliasing.taa | Temporal anti-aliasing, which also steadies the field's light and the reflections over frames. |
reflections | @builtin::systems.reflections.ssr | Screen-space reflections on glossy surfaces, roughness 0.45 and under. Rougher surfaces reflect the sky light's capture alone. |
Cost
The probe field holds its passes to its 1 ms GPU budget: the probes it leaves
out of a frame update on a later one, so its cost stays flat as the scene
changes. Every member scales with the device's quality level
(guides { path = "topics/graphics-quality" }): the values above are the high
level, and lower levels derive from them.
The scene @builtin::systems.sceneLighting.dynamicLightingShowcase places this
setup over a cottage and its garden.