Lighting
A game is lit from its lighting block: in defineGame({ lighting }) for a game made from a template (fps, third-person), or in settings.json for a bundle on the common player. A game that has both must say the same in both, or the build stops (Host/guest settings mismatch: lighting). A level file can carry its own ("lighting" beside "place"): a run lights from its start level's block, else the game's, read as the page starts (lightingOf(game, level)), so a level switch relights when the page loads again, as its place does. Edit mode saves it there. One set of lights, made from that block, lights all three kinds of thing in a scene: the place's gaussians (relit, with as much of their captured light kept as the block says), the triangle meshes (three's own lighting), and the exported splat characters. The page reads the block; game code never lights anything.
json
{
"lighting": {
"style": "night",
"lamps": [{ "near": "door", "color": "warm", "shadows": true, "flicker": true }]
}
}Everything in the block is optional. A style sets the look, and anything written beside it overrides that one value of the style. With no block at all the page adds no lights: the place draws as captured and the characters as stored.
Styles
| Style | Sun | Sky | Place: captured / relight |
|---|---|---|---|
captured | none | grey, 1.2 | 1 / 0 (the default) |
daylight | warm white 2.1, 55° up | blue, 1.4 | 0.8 / 0.4 |
golden-hour | orange 2.4, 9° up: long shadows | violet, 0.7 | 0.35 / 1 |
overcast | none | bright grey, 2 | 0.6 / 0.6 |
night | blue moon 0.35 | dark blue, 0.45 | 0.12 / 1 |
studio | white 2.6, 35° up | white over grey, 1.2 | 0.5 / 0.7 |
noir | hard white 3, 25° up | almost none, 0.15 | 0.08 / 1.3 |
neon | none: magenta and cyan from each side | violet, 0.3 | 0.15 / 1 |
place.captured is the share of the capture's own light kept (0 to 1) and place.relight how strongly the added lights light the place (0 to 2). A dark style keeps little of the capture, or a room captured by day would still glow at night. Each style also has a lamp colour, for a lamp that names none, and a shadow darkness for its lamps.
The block
| Field | What it sets |
|---|---|
style | One of the eight above. Defaults to captured. |
quality | high, auto (the default) or low. See Quality. |
auto | The savings auto makes, each one taken away with false. |
sun | { color, intensity, elevation, azimuth }, or false for none. |
sky | { color, ground, intensity }: the colour from above and the bounce from below; false for none. |
lamps | Up to 16, at most 4 of them spots. See Lamps. |
place | { captured, relight }. |
characters | { wrap, stored, probes }, or false to draw the characters as stored. |
shadows | { quality, casters }: a level (off, contact, simple, soft, auto) and splat props (asset ids) that cast shadows. |
meshProbes | Light triangle meshes from the place's light probe grid. Defaults to true. |
The sun's elevation is degrees above the horizon (0 to 90); its azimuth is degrees round from -z (where the default camera looks), clockwise seen from above.
A colour is #rrggbb or a name: white, warm, cool, candle, moon, red, orange, yellow, green, cyan, blue, purple, pink, magenta.
The block is checked when the game is bundled, and a wrong field is named: Invalid settings.lighting.style: one of captured, daylight, ….
Lamps
A lamp is a bulb (the default; it lights every way) or a spot (a cone). It stands at at (world metres), or height metres (default 1) above the thing near names. near reads words as the world module's find does ("door", "the table"), or is centre for the middle of the place. A name that matches nothing is warned about once, with the things the world does have.
| Field | Default |
|---|---|
color | the style's lamp colour |
intensity | 1: a room lamp's light at half its range |
range | 4 metres |
cone | 30° from the middle to the edge (spot) |
aim | straight down (spot): a point or a name |
shadows | false |
flicker | false: true flickers it as a flame |
A lamp with shadows: true darkens the place beyond whatever stands near it (characters, meshes, casters). The shadows share one depth atlas of 16 tiles: a spot or the sun takes 1 and a bulb 6, so a scene has room for two bulbs' shadows beside the sun's. A lamp whose shadow does not fit is warned about and lights without one. Prefer a spot where a cone will do.
Quality
quality decides what the lighting may cost, once, for the player's device:
high | auto, computer | auto, phone | low | |
|---|---|---|---|---|
| Shadows | soft | soft | simple | contact |
| Lamp shadows | on | on | off | off |
Splat props cast (casters) | on | on | on | off |
| Lamps that light the place | 16 | 16 | 8 | 4 |
Savings (auto) | none | all | all | all |
A phone with 2 GB of memory or less gets low. The cap counts the place's gaussians only, spots first: the meshes take every lamp, and the characters every bulb (not the spots). shadows.quality overrides the level.
Savings
auto makes every saving the block's auto leaves on; "auto": { "bakePlace": false } takes one away. high makes none and low all, whatever the block says.
bakePlaceworks the lights out for each of the place's gaussians once, and draws them with one multiply a gaussian instead of lighting every gaussian every frame. A change of the lights bakes again. A place lit by a lamp that flickers stays live. The bake runs in a worker of its own, so the frame does not stop: the place draws as it was until the new bake lands, then swaps (modeOfsaysbakingmeanwhile). On a 1.6M-gaussian place a bake took 0.65 to 0.82 s in the worker, and the longest frame while it ran was 42 to 54 ms against a 29 ms median (13 Nov 2026, one desktop); the swap itself is about 20 ms. A page that cannot start a worker (a content policy that refuses one) bakes on its own thread and stops for the bake's length. A bake draws no shadows of its own; the shadows stay live.lampSlotskeeps a fixed set of lamps in the scene: four bulbs and two spots from the start, the unused ones dark, more in steps of four bulbs or two spots when a game names more. Without it, a lamp added or taken away changes the number of lights, and three builds every lit mesh's and character's drawing again. On the same page (16 Nov 2026, vsync on), adding a lamp took a 283 to 467 ms frame without slots; with them, no change took longer than 17 ms. The dark slots cost every lit mesh a little each frame; with the page running at the browser's 200 fps cap, no difference showed. A step up to more slots rebuilds once. The place takes only the lamps in use.
What it costs
Measured on 11 Nov 2026 on one desktop, the fps template's 1.6M-gaussian place at 2560×1440, vsync off:
| Setup | Frame (median) |
|---|---|
No lighting block | 11.6 ms |
daylight, baked | 11.7 ms |
daylight, live (bakePlace off) | 11.8 ms |
daylight and a bulb with shadows | 11.8 ms |
With two splat and two skinned characters walking, 13.8 ms with no block and 14.1 ms with a shadowed bulb. The frame follows the pixels drawn more than the lights: the same page took 7.7 ms at 1920×1080. One machine, one place: measure your own.
In a page of your own
The play page and the fps and third-person templates light a game for you, with installSceneLighting(engine, settings, engine.get('world')) once the places are added and lighting.lightCharacters(characters) once the characters are bound. A place added to the scene later (a level switch) is lit as it comes and forgotten as it goes, from the scene's own childadded and childremoved. It publishes the lighting for the page's tools as window.__gameable.lighting (pageLighting()): the block in force, every number it comes to, and a preview that nothing saves. Given { game: definition.lighting ?? null } as a fourth argument, as the templates give it, it also tells them the game's own block (gameSettings), which edit mode previews when a level's own block is taken away. Under it is createSceneLighting:
ts
import { createSceneLighting, type AnimatedGaussianSplat } from 'gameable/splat';
import type { Scene, WebGPURenderer } from 'three/webgpu';
declare const scene: Scene;
declare const renderer: WebGPURenderer;
declare const place: AnimatedGaussianSplat;
const lighting = createSceneLighting({ scene, renderer, settings: { style: 'golden-hour' } });
lighting.lightPlace(place);
// Each frame, for lamps that flicker:
lighting.update(performance.now() / 1000);
// Later, live: the same lamps write numbers only.
lighting.set({ style: 'night', lamps: [{ near: 'centre', shadows: true }] });Pass things (the world module) for near, objectsOf for shadows.casters, and the renderer so a replaced bake's graphics memory is freed. lightCharacters(characters) lights the character bridge, relocate() places near lamps again once a world has loaded, forgetPlace(place) stops lighting one, and modeOf(place) says whether a place is baked, live or baking. The bakes go to createSplatBaker()'s worker; pass one as baker to share it between lightings. resolveLighting(settings) gives every number a block comes to.
The PointLight and DirectionalLight actors create no light: they are placeholders. Light the game from the block instead. The SpotLight actor is a real spotlight that game code drives (a flashlight held to the camera, cameraAttached); it lights meshes, not the place's gaussians.
The splat's own lights
Below the block, AnimatedGaussianSplat.setEnvironmentLighting() mixes captured emission with diffuse image-based lighting. Supply nine world-space RGB radiance SH coefficients (three's SphericalHarmonics3 order), emissionWeight and diffuseWeight. Normals follow the current covariance on the GPU; an authored local normalOrigin or the bounding-sphere centre chooses the outward hemisphere. inputColorSpace: 'srgb' decodes display-referred colours. null restores the original shader. Configure it when the probe changes, not per frame. This is approximate relighting of baked colours: no inverse rendering, recovered materials, occlusion or path tracing.
pointLights: [lamp] takes up to sixteen three PointLights, whose position, colour, intensity, distance, decay and visibility stay live through uniforms: animate them without calling setEnvironmentLighting again. twoSided: true lights both sides of approximate normals in a room; pointLightSoftness bounds near-source attenuation (default 0.25 units). For local lights alone, give nine zero SH coefficients. Point lights cast no splat shadows and do not remove baked light.
The other lights work the same way, up to four of each: directionalLights (the first is the key: a splat's shadow darkens its share alone), spotLights, hemisphereLights and ambientLights. Each adds irradiance as three's own light node does, so at diffuseWeight: 1 a light brightens a splat as much as a white MeshStandardMaterial. wrap (0 to 1) lets light reach past the terminator. setLightingWeights({ emissionWeight, diffuseWeight, wrap }) changes the mix live, any subset, with no rebuild; it throws before setEnvironmentLighting. Static geometry supports all of this on both renderers; dynamic GPU-only geometry needs WebGPU. examples/splat-viewer/?light=day is a live demo.
A prop lit by hand in the bake editor (examples/splat-bake, a bakedLighting file in its assets.json entry) keeps its own look: the block leaves it out.