Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit44fd9e59bd

README.md

ReflectionProbe

A reflection probe: bakes the scene into its own cube slot from its position, so reflective surfaces within its radius mirror the captured surroundings. Multiple probes in a scene are blended by proximity and rank (the renderer's per-fragment probe blend); a surface outside every probe's radius reflects the sky fallback, or the scene's ambient when no sky is captured. The probe renders a small editor-only gizmo marker (cyan octahedron) in edit mode and is invisible in play mode.

Every field is live: editing radius, priority, the proxy or skyFallback in the inspector re-pushes the probe, and reflectionProbe.list() reports what the component holds.

A probe is an authoring-time bake: it loads its persisted baked cube on awake (reflectionProbe.loadBaked) rather than re-baking on every load. A probe reflects once it holds a cube: until it is baked (or has a persisted bake to load) it adds nothing to the frame, arms no sky fallback, reads baked = false in reflectionProbe.list() and in lighting.get's environment.probes, and the engine log names it with the call that bakes it. Set probeId on authored probes so the baked probe_<probeId>.texture asset keeps the same identity across reloads (the runtime entity id changes; the probeId does not).

Public fields:

  • radius (number, default 12) — influence radius in world units. A surface within it reflects this probe at a weight falling from full at the probe to zero at the radius.
  • bakeOnAwake (bool, default false) — opt-in first-time bake on awake (deferred a few frames so geometry is GPU-resident; baking before the scene renders captures black). Only fires when no persisted baked cube exists yet.
  • probeId (string, default "") — stable asset identity for the persisted baked cube. Empty → falls back to the entity id.
  • skyFallback (bool, default true) - once the probe holds a cube, capture the scene's sky into the fallback slot so a surface outside every probe's radius reflects the sky.

Methods: :bake() — (re)bake this probe from its current position into its cube slot and persist it (runs off the calling frame).

-- One-liner (spawns an entity carrying this component):
reflectionProbe.add(0, 3, 0, { radius = 15, probeId = "lobby" })

-- Or attach directly + bake everything once the scene is built:
entity.find("zone").component.add("ReflectionProbe", { radius = 12 })
reflectionProbe.bakeAll()

Max 8 probes (cube slots). Registry policy lives in @builtin::api.engine.reflectionProbe; the generic per-slot capture primitive is the environment module.