Reflections
Reflections — the sky, probes, and the screen
Every standard-PBR surface reflects its surroundings through the environment term: a metal mirrors them at its own colour, a dielectric takes them at a Fresnel weight that is a few percent head-on and rises toward a grazing angle, and the surface's roughness picks how blurred the reflection is. What "the surroundings" are comes from three sources, each one the scene places; with none of them a surface reflects black.
The sky, where the scene asks for its light. environment.ensureSkyFallback()
(or a reflection probe whose skyFallback is set) captures the scene's sky
into the environment, and the capture follows the sky from there, so a chrome
ball reflects the sky it stands under and a wet floor reflects the horizon at
a grazing angle; environment.setSkyFallback(false) takes it out again.
Drawing a sky puts nothing in the environment by itself.
The modules.api.engine.environment.drawnSky follower (follow()) keeps whatever sky is drawn (a sky component,
an ecs.Sky material row or a content sky shader) captured there for the rest
of the session.
renderer.reflectionEnvironment() reports it as sky / skyCaptured.
A reflection probe, where a surface should reflect the room. A probe bakes
the scene around one point into a cube; surfaces within its radius reflect
that cube instead of the sky, at a weight that falls from full at the probe to
zero at the radius, and beyond every probe's radius a surface reflects the sky
again. Place one per room, size radius to the room, and give it a box
proxy sized to the walls so the reflection stays anchored as the camera moves:
entity.find("lobby").component.add("ReflectionProbe", {
radius = 12, proxy = "box", proxyExtentX = 6, proxyExtentY = 3, proxyExtentZ = 6,
probeId = "lobby", -- the baked cube's stable identity across reloads
})
reflectionProbe.bakeAll() -- bake every probe once the scene is built
Every field is live in the inspector. Two probes that overlap crossfade by
proximity; a small probe ranked above the large one it sits inside (priority)
wins outright where it reaches full weight. The baking toolbox's
reflections tool places and bakes a covering set across the scene in one
call, and its clear tool removes them. Up to eight probes are seated at
once; reflectionProbe.list() names them. A probe reflects once it holds a
baked cube: one that is placed and never baked adds nothing to the frame, reads
baked = false in reflectionProbe.list() and in lighting.get's
environment, and the engine log names it with the call that bakes it.
Screen-space reflections, for what moves. A probe records the room as it
was baked; a character walking across a polished floor is not in it. The
@builtin::systems.reflections.ssr render feature reflects whatever the camera
can see this frame, gathered over each surface's own lobe, on every surface up
to its roughnessCutoff (where it starts handing over to the probes and the
sky), with nothing authored per surface. List it on the scene's RenderFeatures
entity:
entity(entity.spawn("render features").id).component.add("RenderFeatures", {
features = {
{ feature = "@builtin::systems.reflections.ssr", settings = { intensity = 1.0, maxDistance = 40, quality = "high" } },
},
})
Only what is on screen can be reflected, so reflections fade toward the frame
edge, and where the rays find nothing the surface keeps the probe or sky it
reflected already. What the screen found stands in for the environment inside
the material's own shading — two passes write the scene's reflection channel at
the afterDepthPrepass seam, once the visibility raster has laid this frame's
depth, and the material's environment term reads it the same frame — so a
metal's colour tints it and a dielectric shows it by its angle, each by the
rule the material states, the reflection stands where the camera is now, and
the reflection capture pass shows it. The package's guide covers every knob:
guides { path = "systems/reflections" }.
Which to reach for: the sky is already there; add probes when a room's walls should show in its floor; add the component when moving things should.
Seeing what a surface reflects. capture { pass = "reflection" } draws
every surface as the environment it reflects — the probes whose radius
reaches it and the sky under them, along its reflection vector at its own
roughness mip, and the screen-space reflection traced for it where one was —
before Fresnel and albedo weigh it into the lit frame. A mirror
reads as the room it mirrors, a rough surface as that room blurred, a point no
probe reaches as the sky, and with the sky fallback off as black. It answers
whether a probe reaches a surface, whether its proxy anchors the room as the
camera moves, and how far a roughness blurs it, without the lit pixel in the
way.
Making a wet street reflect
A wet street, a polished stone floor and a lacquered counter reflect the same way. Three sources combine at every pixel, and the surface's roughness decides how much each one shows.
Three sources, one pixel. The sky is the fallback. Probes are the room as it was baked, already blurred to the surface's roughness. Screen-space reflections are what the camera sees this frame, gathered over the same lobe the roughness describes: each pixel traces a ray drawn from that lobe and takes the rays of its neighbours that stand on the same surface, so a bright sign becomes the soft, stretched streak its lobe spreads it into. Screen-space reflections cover the part of the lobe they found on screen and the probe fills the rest, so a sign that is half off the top of the frame reflects as the half the screen holds plus the probe's answer for the other half. A surface rougher than the screen-space handover takes the probe alone.
Roughness decides the look. Below about 0.1 a surface is a mirror and shows a sharp image. From 0.2 to 0.6 it shows glossy streaks that widen and soften as the roughness rises; wet asphalt reads best around 0.3 to 0.5. From about 0.7 the probe's soft blob carries most of it. Puddles are separate, lower-roughness surfaces laid over the street, and they read as mirror patches inside the glossy reflection.
The roughnessCutoff setting of the screen-space reflections feature is
where it starts handing over to the probes: a surface at or below it takes the
full screen-space reflection, and one a tenth above it takes none. The default,
0.75, covers wet and polished surfaces. A scene that authored a lower value (the
old default was 0.4, and 0.45 was common) leaves wet asphalt to the probes, so
raising it is the first thing to check when a street does not reflect its signs.
What screen-space reflections reflect. Only what is on screen: a sign above
the top of the frame appears through a probe, and so does whatever stands behind
the camera. A probe places a reflection correctly when it has a box proxy sized
to the street; with no proxy the probe treats everything as infinitely far away,
and the reflection lands in the wrong place and stretched. Only opaque and
cutout surfaces take a screen-space reflection: the trace runs over the
surfaces the depth holds, so a pane of glass and any other blended surface
(a blend other than opaque or cutout) reflect their probes and the sky,
or what their shader traces for itself through
@builtin::shaderModules.screenReflection.
How to check. The reflection capture pass shows what each surface reflects
before Fresnel and albedo weigh it in. A streak there that does not show in the
lit frame means the surface's Fresnel or its albedo is hiding the reflection,
and the reflection itself is in place. A single capture draws the view once, so
its reflection holds more grain than the view as it runs.