Skip to content

Light probes

Updated

Real light bounces. A red wall tints the floor beside it, a room with a single window is bright near the window and dim in the corners, and the space under a table is darker than the space above it. Computing that every frame is far too expensive for a browser, a phone or a headset. Light probes compute it once, in the editor, and save the result. In play, rooms are then lit by their own bounced light, with soft shadows and darkened corners, at almost no cost.

A Light Probe volume holds the baked data for a box. The Light Probe Solver on the scene root bakes every volume at once. This page explains how both work, how to size them, and what a script can read and do with them.

  • Light probes add to real-time lights; they do not replace them. Read Lights and Shadows first.
  • Baking only happens in the editor. Scripts that bake are editor scripts, which run only in the editor, behind buttons. See Scripting.
  • Components are reached with entity.getComponent(Class). See Components.
  • Probe. A point in space that records the light arriving from every direction. A volume holds a regular grid of them.
  • Indirect light. Light that reached a surface after bouncing off another one. Probes capture it, so colours bleed and shade gathers in corners.
  • Baked shadow. How much of each shadow-casting light, and of the sky, reaches each point of the box, stored in a 3D texture.
  • Ambient occlusion. Darkening of indirect light close to nearby blockers, such as under furniture and in corners.
  • Bake. The editor step that renders the scene from every probe and stores the results in the volumes.
  1. You place one or more Light Probe volumes (ent-light-probe) around the areas to light, usually one per room.
  2. In the editor, the Light Probe Solver (on the scene root) renders the scene around every probe and saves what each one sees into its volume. For volumes that receive baked shadows, it also bakes how much of each shadow-casting light, and of the sky, reaches each point of the box.
  3. In play, each volume uploads its saved data once. Every lit built-in material (Standard, Physical, Lambert, Phong, and Shader Materials with lit or toon shading) samples it. Shader Materials take the probe light but no baked shadows, since they receive none. Nothing runs per frame on the CPU.

Inside a volume, the probes’ diffuse light replaces the Environment’s, so a room is lit by the room: its lamps, its wall colours, its shade. Reflections stay the Environment’s everywhere.

LightProbeComponent (comp-light-probe) is the volume. Its box is a 1 m cube placed, sized and turned by the entity’s transform. A new Light Probe entity is 4 × 3 × 4 m, and it turns about the vertical axis only. It bakes and lights the axis-aligned box around the turned volume.

Prop Type Default Description
lightingQuality number 0.5 How fine its probes are, 0 to 1.
receiveBaked boolean true It receives baked shadows (from lights with an enabled Light Shadow) and ambient occlusion.
shadowQuality number 0.5 How fine its baked shadows are, 0 to 1.
lightingData string none The baked probes, written by the solver. Absent until baked.
shadowData string none The baked shadows and ambient occlusion, written by the solver. Absent until baked.

Each equal step of quality makes the spacing finer by the same factor:

Quality Probes apart Shadow texels apart
0 4 m 1 m
0.25 2 m 0.47 m
0.5 1 m 0.22 m
0.75 0.5 m 0.11 m
1 0.25 m 0.05 m

A volume holds 2 to 16 probes per axis, and at most 128 shadow texels a side, so a very large box gets wider spacing than its quality asks. Higher quality bakes longer and uses more memory: the counts grow with the cube of the detail.

Size it past the walls. At its faces, probe light fades into the Environment’s over half a probe spacing. A face inside the room shows as a seam on what stands near it.

Data follows the box. Data baked for another box or another lightingQuality is kept, but lights nothing until you bake again. Moving or scaling a volume in play does not move its light.

Member What it is
isBaked true once its data was baked for its current box and lightingQuality, so it lights the scene.
drawsShadows true when its scene draws this volume’s baked shadows.
issue A sentence saying why it lights or shadows less than its props say, or undefined.

A volume with receiveBaked also stores soft shadows and ambient occlusion.

  • Which lights: every Spot and Point light whose Light Shadow is enabled, and only those. A Directional Light casts no shadows, so it bakes none. All lights light the probes, shadowed or not.
  • Which casters: the meshes a Shadow component makes cast, where they stand at bake time.
  • Real-time and baked together: a baked light also casts its real-time shadow, and takes the darker of its live shadow and the baked one. Static things keep the soft baked shadow; moving things still cast a live one.
  • Ambient occlusion darkens the indirect light near blockers. Only blockers within 1 m count, so a high ceiling leaves a room lit, and only corners and the floor under things darken.
  • Each kind of light (point, directional, spot) has its own channel. One light of each kind bakes exactly; several of one kind share their channel.
  • Surfaces that do not receive shadows take neither the baked shadows nor the occlusion.

Play cost: one small 3D texture uploaded once, and one texel read per lit pixel inside the box. Nothing outside it. It is world space, so both XR eyes agree.

LightProbeSolverComponent (comp-light-probe-solver) goes on the scene root and bakes every enabled volume of the scene. It works only in the editor; in play the volumes use their saved data.

Prop Type Default Description
cubemapSize number 16 Size of each cube face a probe renders, in pixels: a whole number, 4 to 64. Common choices: 4, 8, 16, 32, 64.
near number 0.1 Nearest distance a probe sees, in metres. Less than far.
far number 100 Farthest distance a probe sees, in metres, up to 1000. More than near.
bounces number 1 Extra passes that add light bounced off lit surfaces: a whole number, 0 to 3.
softness number 0.3 How soft the baked shadows are, 0 (sharp) to 1: the size of the lights.
samples number 32 Light positions averaged into the baked shadows: a whole number, 4 to 128.
occlusion number 1 How much the baked sky occlusion darkens ambient light, 0 to 1.
Method What it does
bake(onProgress?) Bakes every volume, then saves all their data at once, so no volume’s new probes light another’s bake. Returns a promise of whether it baked. onProgress(progress) receives 0 to 1.
cancel() Stops the bake under way at its next step. Nothing is saved, the volumes keep their data, and bake resolves false. Returns false when no bake is running.
reset() Clears every volume’s lightingData and shadowData, so they light and shadow nothing until baked again. Editor only. Returns false when there is nothing to clear.

bake resolves false when there is nothing to bake or it cannot bake: in play, while presenting in XR, while another bake runs, or when it is stopped (by cancel(), or because the solver was removed or disabled, or the editor was left).

The bake never blocks the editor: it works in small steps each editor frame, reports progress and lets the editor draw. While it renders, editor drawings and the volumes’ current probes are hidden, so they neither show nor light the bake.

A room has a volume named Kitchen Probe and a low Hemisphere Light named Kitchen Fill. If the volume is not baked, the fill light is raised so the room is not too dark.

FallbackFill.jx
#pragma lifecycle(startup)
const BAKED_FILL = 0.15; // a touch of fill on top of the baked light
const UNBAKED_FILL = 0.7; // enough to see the room without its bake
function startup() {
const probe = findEntity('Kitchen Probe').getComponent(LightProbeComponent);
const fill = findEntity('Kitchen Fill').getComponent(HemisphereLightComponent);
fill.setProps({ intensity: probe.isBaked ? BAKED_FILL : UNBAKED_FILL });
}
  • The script reads the volume’s state once and sets a light’s intensity accordingly. The light already exists, so nothing is recompiled.
  • A Hemisphere Light is the cheapest fill: it has no shadows and costs very little per pixel.
ProbeCheck.jx
#pragma lifecycle(startup)
function startup() {
const probe = findEntity('Light Probe').getComponent(LightProbeComponent);
if (probe.issue) console.warn(probe.issue);
log('baked:', probe.isBaked, 'draws shadows:', probe.drawsShadows);
}
  • isBaked is false when the volume was never baked, or was moved or resized since its bake.
  • issue explains in words why the volume lights or shadows less than its props say. console.warn writes it to the script log as a warning.
  • Reading these members is free: they do not trigger any work.
ProbeReport.jx
#pragma lifecycle(startup)
function startup() {
let total = 0;
let unbaked = 0;
for (const entity of scene.entities.values()) {
const probe = entity.getComponent(LightProbeComponent);
if (!probe) continue;
total++;
if (!probe.isBaked) {
unbaked++;
console.warn(`${entity.name}: not baked for its current box or quality`);
} else if (probe.issue) {
console.warn(`${entity.name}: ${probe.issue}`);
}
}
log(`${total} light probe volumes, ${unbaked} need a bake`);
}
  • scene.entities is a Map of every entity in the scene; walking it once at startup is fine.
  • The report tells you which rooms will fall back to the Environment’s light because their volume needs baking again.
  • Run it while testing, then remove it: it does nothing a player needs.

This is an editor-only tool script: it exists only in the editor, never in the player. Its buttons appear in the Behavior’s properties. The scene root (here named Main) carries the Light Probe Solver.

BakeTools.jx
#editor_only
#pragma slot(ref=bakeLighting, type=Button, label="Bake lighting", on_event=onBake)
#pragma slot(ref=cancelBake, type=Button, label="Cancel bake", on_event=onCancel)
#pragma slot(ref=clearBake, type=Button, label="Clear baked data", on_event=onClear)
function solver() {
return findEntity('Main').getComponent(LightProbeSolverComponent);
}
async function onBake() {
let lastShown = -1;
const baked = await solver().bake((progress) => {
const percent = Math.round(progress * 100);
if (percent >= lastShown + 10) { // log every 10 %
lastShown = percent;
log(`Baking… ${percent}%`);
}
});
log(baked ? 'Lighting baked' : 'Nothing baked');
}
function onCancel() {
if (!solver().cancel()) log('No bake is running');
}
function onClear() {
if (solver().reset()) log('Baked lighting cleared');
else log('Nothing to clear');
}
  • #editor_only makes the whole script editor code: the player never downloads or runs it.
  • Each #pragma slot(... type=Button, on_event=...) adds a button that calls the named function when pressed.
  • bake returns a promise of true or false. It is false when the bake was cancelled or could not run, so the message is always accurate.
  • onProgress receives values from 0 to 1. Logging only every 10 % keeps the log readable.
  • cancel() and reset() return false when there was nothing to do.

An editor-only script that raises the quality of the volume currently named Lobby Probe, then bakes.

LobbyQuality.jx
#editor_only
#pragma slot(ref=bakeLobby, type=Button, label="Bake lobby in high quality", on_event=onBakeLobby)
async function onBakeLobby() {
const probe = findEntity('Lobby Probe').getComponent(LightProbeComponent);
probe.setProps({ lightingQuality: 0.75, shadowQuality: 0.75 }); // 0.5 m probes, 11 cm shadows
const solver = findEntity('Main').getComponent(LightProbeSolverComponent);
solver.setProps({ bounces: 2, samples: 64 });
const baked = await solver.bake();
log(baked ? 'Lobby baked' : 'Bake did not run');
}
  • Changing lightingQuality makes the old data stop lighting until the next bake, so the script bakes right away.
  • More bounces brightens rooms lit mainly by indirect light; more samples smooths the baked shadows. Both lengthen the bake, not play.
  • The solver bakes every volume, not only the lobby. Raise quality only where it shows, since memory grows with the cube of the detail.
  • Expecting a bake in play. bake resolves false in play and in XR. Bake in the editor and save the scene.
  • A volume that stops at the walls. Light fades at its faces, which shows as a seam. Make it a little larger than the room.
  • Moving a volume after baking. Its data no longer matches its box and lights nothing until you bake again. isBaked tells you.
  • Moving lights or walls without baking again. The baked light still shows the old layout.
  • Expecting a sun’s shadow in the bake. A Directional Light casts no shadows, real-time or baked. Use Spot or Point lights with a Light Shadow for baked shadows.
  • No shadows from an object in the bake. Its Shadow component must make it cast.
  • Very high quality everywhere. Memory and bake time grow with the cube of the detail.