Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

Looks

A look is a finished setting for a scene’s light. Import one and hand it to Landscape, and it sets the following together:

  • The soft light and reflections every model’s material takes from the sky.
  • Fog.
  • Exposure.
  • A colour grade.
  • A post-processing stack.
  • A soft light that only characters receive, as Lighting characters says.

A game that picks no look draws with the daylight rig alone.

import { Landscape } from "@spawnite/engine";
import { dusk } from "@spawnite/engine/looks/dusk";
export function DuskScene() {
return <Landscape map="meadow" look={dusk} />;
}

A look adds nothing to your game’s download: it lights the scene from the sky the engine draws.

A look’s hour is on the engine’s day clock, not a wall clock. The sun rises at hour 0, is highest at 10 and sets at 20, and the night runs from 20 to 24, with midnight at 22. A look whose day is keyframes moves the sunrise and the sunset to its own. On the engine’s arc the sun peaks at 55 degrees, and a look raises or lowers it with sunElevationRadians.

Look Hour What it looks like
noon 10 A clear meadow with the sun high.
morning 2.4 A low sun through a light haze.
dusk 19.3 A warm sun on the horizon, and a strong glow.
night 22 Midnight: the moon over a dark blue meadow.
overcast 10 Soft light from a grey sky, and close fog.
pixel 10 A 2D game’s art in the colours its file holds.
diorama 17.2 A pixel diorama’s low gold sun and blue night.

Each look lights the scene’s materials from the sky the scene draws. The daylight rig draws that sky once into a cube when the look mounts, and three.js filters it into the scene’s environment. The sky it bakes is one of the following:

  • An image as the Landscape’s sky, as A scene without a map shows: the image as the scene draws it, with its anchors, haze and intensity, turned with it every frame.
  • Otherwise the engine’s own sky at the look’s hour: the scattering sky, the zenith’s blue, the cloud decks, the warm band at the horizon and a ground below it, which the light off the ground replaces in a Landscape that draws its ground. A look that paints the sky bakes the painted one in place of the scattering sky. A game that draws no sky, with sky={false}, takes its light from this one.

The bake holds no lights, fog, models or post-processing. It runs under the loading screen, so it costs no drawn frame. An avatar’s MToon material takes the same light: three.js hands the environment only to its own standard, Lambert and Phong materials, so the engine adds the environment’s diffuse light to MToon’s sky light itself.

The daylight rig keeps the sky and the light in agreement every frame:

  • It clips the sky’s own sun, because the rig’s directional light is the sun and casts the shadows. Left in, the sky’s sun would light every shadow.
  • It scales the environment’s light with the hour, as it scales the hemisphere fill. At the look’s hour the light is the look’s environment.intensity.
  • It multiplies the hour’s exposure by the look’s.
  • It dims the fog with the light on the ground, the sun and the fill together. The fog keeps the look’s colour at the look’s hour and at any brighter hour, and darkens as the light falls after it, so it never glows past a scene the night has darkened.

A look opens the Landscape on its hour. Pass startHour to open elsewhere, unless the map’s level settings name an hour, which wins over both. The day clock still runs, so the drawn sky and the sun follow the hour from there. The bake keeps the look’s hour, and the rig scales its light with the hour instead of drawing it again.

Unity lights a scene from its skybox by default, Godot from its Sky resource, and Unreal’s Sky Light captures the sky it draws. A look lights from the sky the scene draws in the same way, and takes an image in its place as each of them takes a cubemap.

In a Landscape that draws its ground, the light from below is the ground’s own: the sunlit ground throws up its colour, so the shade under a figure, a stump or a rock takes the warm green of the grass around it. The rig draws the ground’s colour from above once as the Landscape loads, and again when its textures land. Each frame it lights that colour with the sun, shadowed at the ground, and with the sky, and blurs it over about 2 m.

A face looking down takes that light in full, a face looking sideways half of it, and a face looking up none, as it took the fill’s ground colour before. The fill’s fillGroundColor and the ground the sky’s bake draws under its horizon give way to it, so the light from below is counted once. A moving sun, a new hour and a changed look rebuild nothing.

The bounce is diffuse light only. While it runs under the engine’s sky or a painted one, a glossy or metal face looking down reflects no ground, since the bake leaves its lower half dark. A look’s environment.image keeps its whole sphere instead, as Lighting from an image says.

To light the ground yourself, such as a toon ground or a baked look, pass bounceLight={false} to the Landscape. The ground draws as before, and the light from below goes back to the fill’s fillGroundColor and the lower half of the sky’s bake. The bounce then draws none of its passes. Turning it on or off bakes the sky’s light again, and makes or frees the bounce’s maps. The fill’s ground colour also lights from below where no bounce runs:

  • A Landscape with ground={false}.
  • A Lighting with no Landscape.
  • A WebGPU renderer, which draws no bounce.

The light comes off the ground alone: a canopy or a wall throws no light of its own yet. Unity, Unreal and Godot bake light off the ground into light maps and probes from a fixed sun; this stores only the ground’s colour, so it follows the live sun. Unity’s Contribute Global Illumination flag, Unreal’s Affect Dynamic Indirect Lighting and Godot’s gi_mode switch an object’s part in their bounce, and bounceLight is that switch for the ground.

To light the scene from an equirectangular .hdr or .exr in place of the engine’s sky, name it as the look’s environment.image, with sunU, the column its sun stands in from 0 to 1 across. The rig clips the image’s sun, turns the image so its sun stands on the rig’s, and keeps the look’s intensity unless you name another. image: false drops a base look’s image and lights from the sky again. Put the image in your game’s public/assets folder and name it by its path. The engine’s tests mount this file:

packages/engine/test/outside/SunsetScene.tsx
import { Landscape } from "@spawnite/engine";
import { dusk } from "@spawnite/engine/looks/dusk";
// Dusk, lit from an image in the game's public/assets folder in place of
// the engine's sky.
export function SunsetScene() {
return (
<Landscape
map="meadow"
look={{
base: dusk,
environment: {
image: { file: "/assets/sunset.hdr", sunU: 0.6 },
},
}}
/>
);
}

An image keeps its whole sphere: its lower half lights the faces looking down and shows in glossy reflections, and the ground’s bounce does not run. Unreal’s Sky Light draws a black lower hemisphere by default instead. To light from below with the drawn ground under an image, pass bounceLight to the Landscape: the bounce then runs, and the image’s lower half goes dark, so the light from below counts once.

The image is downloaded before it lights the scene: until it arrives the models take no light from the environment. A 1K HDRI from Poly Haven is about 1.5 MB. A change between an image and the sky compiles every lit material once more.

While the sun is below the horizon, the same directional light is the moon. The moon stands opposite the sun, so it rises at sunset and sets at sunrise, and its light is a cool blue that follows its own height and peaks at midnight. The moon casts the shadows at night, and a night costs no more to draw than a day. By default the exposure falls to a quarter at night, so the sky goes truly dark and the meadow is lit by the moon.

A look’s daylight colours the day. Four of its values colour the hours the sun is low or gone:

  • horizonSunColor: the sun’s colour as it reaches the horizon, at dawn and dusk alike. The key blends to it from sunColor as the sun falls.
  • moonColor: the moon’s light.
  • nightFillColor: the colour the hemisphere fill’s sky side turns to through twilight.
  • nightExposure: the night’s exposure as a multiple of the day’s, 0.25 by default, so a game whose players work at night raises it.

A look that leaves a colour out keeps the engine’s. An override replaces daylight whole, so it names every colour it keeps. The engine’s tests mount this file:

packages/engine/test/outside/NightShiftScene.tsx
import { Landscape } from "@spawnite/engine";
import { noon } from "@spawnite/engine/looks/noon";
// A day with an orange sunset and a blue night bright enough to work in:
// the night keeps 60% of the day's exposure, not the engine's quarter.
export function NightShiftScene() {
return (
<Landscape
map="meadow"
startHour={22}
look={{
base: noon,
daylight: {
horizonSunColor: "#ff7a2e",
moonColor: "#c8d6ff",
nightFillColor: "#5a7ee6",
nightExposure: 0.6,
},
}}
/>
);
}

The four colour the key and the fill alone. An image’s pixels, the sky’s bake at the look’s hour, the clouds, the fog and the light on characters keep their own colours. Unity, Godot, Roblox and PlayCanvas keep the direct light’s colour, the ambient light and the exposure as separate controls, and a game scripts them over its day; a look sets each end once and the rig blends between them as the clock runs.

A look’s daylight can hold keyframes instead of colours: each keyframe is one hour’s sky, key light, fill, fog, exposure and shadow. Between two keyframes each value follows a monotone cubic in linear light, so it changes smoothly, never passes either keyframe, and wraps at midnight with no jump. Keyframes replace the colours above, so a look colours its sun one way. Luminati keys its day the same way; Unity, Unreal and Godot leave a day to curves a game scripts over its own fields.

sunriseHour and sunsetHour say which day the keyframes were chosen for, and the engine’s arc rises and sets at those hours. The arc still stands the sun: northOffsetRadians turns it and sunElevationRadians raises it. A keyframe’s moonShare turns the one key light from the sun, at 0, to the moon, at 1, so the night keeps its shadow with no second shadow map. Each keyframe holds the following:

  • hour, from 0 to just under 24.
  • skyTopColor and skyHorizonColor. The fog takes the horizon’s colour, so the far ground melts into the sky.
  • sunColor and sunIntensity, as three’s DirectionalLight takes them.
  • fillSkyColor, fillGroundColor and fillIntensity, as three’s HemisphereLight takes them.
  • fogDensity, the density of the look’s exponential fog.
  • exposure, the renderer’s tone-mapping exposure, more than 0.
  • shadowIntensity, how dark the shadow falls from 0 to 1, and shadowRadius, its filter’s spread in texels.
  • sunGlow, how strongly the sky glows round the sun.
  • moonShare and nightShare, from 0 to 1. The night’s share is what lamps and the grade read.

The engine’s tests mount this file:

packages/engine/test/outside/KeyframedDayScene.tsx
import { Landscape, type LookDaylightKeyframe } from "@spawnite/engine";
import { noon } from "@spawnite/engine/looks/noon";
// A day of two keyframes: a warm afternoon and a blue, moonlit midnight.
// Every hour between blends the two, and the sun rises at 6 and sets at 19.
const afternoon: LookDaylightKeyframe = {
hour: 15,
skyTopColor: "#4880d8",
skyHorizonColor: "#dde2da",
skyBottomColor: "#9eb0c0",
cloudCoverage: 0.42,
sunColor: "#ffe0b0",
sunIntensity: 3.6,
fillSkyColor: "#9cb8e8",
fillGroundColor: "#786248",
fillIntensity: 1.1,
fogDensity: 0.012,
exposure: 1,
shadowIntensity: 1,
shadowRadius: 2.5,
sunGlow: 0.8,
moonShare: 0,
nightShare: 0,
};
const midnight: LookDaylightKeyframe = {
hour: 0,
skyTopColor: "#050a1f",
skyHorizonColor: "#1b2a5c",
skyBottomColor: "#0a1232",
cloudCoverage: 0.3,
sunColor: "#7294ff",
sunIntensity: 1,
fillSkyColor: "#3656c0",
fillGroundColor: "#1a2042",
fillIntensity: 1.6,
fogDensity: 0.022,
exposure: 1.36,
shadowIntensity: 0.6,
shadowRadius: 3.2,
sunGlow: 0.4,
moonShare: 1,
nightShare: 1,
};
export function KeyframedDayScene() {
return (
<Landscape
map="meadow"
look={{
base: noon,
hour: 15,
daylight: {
keyframes: [afternoon, midnight],
sunriseHour: 6,
sunsetHour: 19,
},
fog: { startBeforeFocus: 7 },
}}
/>
);
}

The look’s sun, fill and exposure still multiply what the keyframes give. Its fog is the exponential one with neither colour nor density, since the keyframes give both, and a look that sets either beside keyframes is an error in development. A painted sky takes the keyframes’ colours at the look’s hour. Two or more keyframes at different hours are required, in any order.

Every look, keyframed or not, writes one record of the hour’s light each frame, which useLookDaylight reads: the key light, the fill, the sky’s colours, the fog, the exposure, the shadow and the night’s share. The rig writes it after the frame’s steps and camera and before the scene’s frame callbacks of the default priority, so a lamp that reads the night’s share in its own useFrame reads this frame’s.

The engine’s scattering sky is white near the horizon whatever its settings, and a camera that looks down on a scene sees only the lowest few degrees of sky. To give that strip a colour of your own, set the look’s sky: a gradient from topColor overhead to horizonColor at the horizon, as Godot’s procedural sky and Unity HDRP’s gradient sky paint one. The painted sky replaces the scattering sky, which then costs nothing to draw.

The gradient keeps one colour through the day, and sunsetColor carries the hour. It glows over the horizon on the sun’s side: none at noon, most of it through the late afternoon, and all of it with the sun on the horizon. Set horizonColor to the noon horizon and sunsetColor to the gold of a low sun. curve sets how low the top colour reaches: at 0.15, the default, the two colours meet halfway 9° up, and a smaller curve brings the top colour lower, 2.5° up at 0.04. span sets how high the glow reaches, as a share of the way from the horizon to straight up: 0.25 by default. The colours are the ones shown at the look’s hour, which the Landscape opens on. The engine’s tests mount this file:

packages/engine/test/outside/IslandSkyScene.tsx
import { Landscape } from "@spawnite/engine";
import { noon } from "@spawnite/engine/looks/noon";
// A late-afternoon sky over a sea: blue overhead, a pale horizon at noon
// that warms to gold as the sun falls, and a ring of cloud banks in place
// of the flat decks.
export function IslandSkyScene() {
return (
<Landscape
map="meadow"
look={{
base: noon,
hour: 17,
fog: { color: "#b8835a", near: 110, far: 380 },
sky: {
topColor: "#2a78c2",
horizonColor: "#8fa6b8",
sunsetColor: "#e8a050",
curve: 0.04,
span: 0.06,
clouds: false,
cloudBanks: { color: "#d9a87e", shadeColor: "#6e5276" },
},
}}
/>
);
}

Every colour is an input before the look’s exposure and tone mapping, in the same light as the fog’s colour, so it shows brighter than its swatch. An override gives sky whole, since its colours are chosen together, and a look that lights from environment.image cannot paint one. The sky dims with the light on the ground as the fog does, so the night darkens it. Its lowest 3° take the look’s fog colour, so the far sea meets the sky without a seam. A fog the Landscape names in place of the look’s keeps its colour at every hour, so choose its colour against horizonColor.

Two kinds of cloud draw over it:

  • clouds, the engine’s flat decks overhead, with your colours, coverage, height and size. Within a few degrees of the horizon a flat deck only streaks, so a camera that looks down sees little of it.
  • cloudBanks, faceted banks that stand in the world over the map, as stylised island games draw cloud. Climbing, zooming and walking shift them against the sky, and they drift with the look’s wind. color is on top and shadeColor beneath, both reddened by the hour as the sun is. Cloud banks sets where they stand, their shapes and their speed.

The painted sky and the decks stand on the camera’s eye, as a sky box does, so a deck’s height is above the eye however high the camera stands. A Landscape’s own sky replaces the painted one on screen. Under sky={false} the bake still lights from the painted sky, and an image as the sky lights the scene in its place. Look holds the contract of its sky.

The banks fill a square round the camera’s eye, which wraps as they drift, so a walk never leaves them behind. A bank grows in past minDistance metres across the ground from the eye and shrinks away by maxDistance. Its base stands minHeight to maxHeight metres over the map’s origin. Stand them above the camera’s highest point, and low and far enough for its view: a camera that looks down sees only a few degrees over the horizon. Juice Island stands 64 banks 480 to 820 m off and 28 to 60 m up.

Each bank is a long low strip, a tall narrow heap, or a lone puff or two. minPuffs and maxPuffs, minPuffRadius and maxPuffRadius, and minWidth and maxWidth set the ranges a bank’s shape is drawn from. seed picks another layout and other shapes.

Half the banks drift at speed metres a second toward the wind’s direction, and the rest at 0.6 of it, which reads as two layers. They drift on the effects’ clock, so a pause holds them, and a look with wind: false holds them still. Unity’s HDRP cloud layer and Godot’s sky draw cloud on the sky itself, which no walk shifts; Unreal’s volumetric clouds stand in the world, as these do.

Every bank draws in one draw call. The engine’s 32 banks are 14,800 triangles, and Juice Island’s 64 are 22,880. Measured at Low on an RTX 3070 on 2026-10-16, Juice Island’s banks added one draw and 22,819 triangles to the frame. The GPU’s mean frame time moved by less than the run-to-run noise, 4.14 ms on against 4.07 ms off.

sky: { style: SkyStyle.Pixel } draws the sky as pixel art, a dome behind everything else on screen, as Luminati’s diorama does. Its clouds snap to cells of one angular size, cellsPerRadian, 380 by default, so a cloud’s pixel keeps its size on screen however the camera turns. Their cover and their light take three steps each. The sun is a disc of 12 cells bright enough to bloom, the moon one of 14 with its craters and phase, and two layers of stars come out at night.

Under keyframes, each keyframe gives the sky’s skyTopColor, skyHorizonColor, skyBottomColor and cloudCoverage by the hour, and a look that sets the sky’s own colours or coverage beside them is an error in development. On the engine’s arc, topColor, horizonColor, bottomColor and coverage set them, and the night dims them. seaOfClouds, from 0 to 1, lays clouds below the horizon. The pixel sky lights nothing, so a look that draws one sets environment to { intensity: 0 }. Godot’s and Unity HDRP’s gradient skies take the same three colours. Look holds every field.

At the diorama’s camera, which sees none of the sky, the pixel sky drew the scene 0.09 ms faster than the scattering sky it replaces. Measured on 2026-10-18 with spawnite play profile --gpu-passes on the diorama’s square at the golden hour, 1920 by 1080 on an RTX 3070, the median of three interleaved runs.

The sun and the sky dim as the sun falls, so a look tuned to a low afternoon sun overexposes the morning. Its daylight.exposureAdaptation, from 0 to 1, lowers the exposure through the hours whose ground takes more light than at the look’s own hour. At 1 it fully offsets the estimated light the ground gains over that hour; at 0, the default, the exposure stays as the hour gives it. It never raises the exposure, so dusk and the night keep theirs, and the night’s own exposure ramp still applies on top. It draws at every quality level.

The light it reads is an estimate: the sun at the angle it strikes flat ground, the fill, and the environment, dimmed with the sky. Shadows, colours, the moon and local lights are left out. Unreal, Unity and Godot meter the rendered frame for their auto exposure; this reads the hour instead, so a shot of an hour is the same every time. The look’s hour is its anchor, and a Landscape’s startHour does not move it. A look that sets it needs light at that hour, and a sun, fill and environment intensity of 0 or more, or the Landscape refuses it. Look holds its contract.

On the engine’s arc the hour sets the sun’s height as well as its bearing, and the sun never stands higher than 55 degrees. sunElevationRadians sets the sun’s height over the horizon at the look’s hour, such as 1.1 for a summer noon’s 63 degrees. The day’s arc is scaled to pass through it. The sun still rises at 0 and sets at 20 on the same bearing, and as the clock runs every hour stands higher or lower by the same share. The engine’s tests mount this file:

packages/engine/test/outside/SummerAfternoonScene.tsx
import { Landscape } from "@spawnite/engine";
import { noon } from "@spawnite/engine/looks/noon";
// An early afternoon under a summer sun: the hour keeps the sun's bearing
// and its light, and the sun stands 65 degrees up, over the 50 the day's
// arc gives at this hour.
export function SummerAfternoonScene() {
return (
<Landscape
map="meadow"
look={{
base: noon,
hour: 12.8,
sunElevationRadians: (65 * Math.PI) / 180,
}}
/>
);
}

It moves the sun alone. Its intensity and colour, the sky’s painted tint, the warm band, the clouds and the night stay what the hour gives, so a look tuned at its hour keeps its key light. The ground takes more of that light from a higher sun, because it strikes more steeply. The engine’s scattering sky is drawn from the sun’s direction, so it follows the height, and so does the light the scene takes from it. The moon stands opposite the sun as drawn. A painted sky keeps the height its sun is painted at, so set the value to that height for the light and the painting to agree.

The value is over 0, at an hour the sun is up. It is at most what keeps the arc under straight up: Math.PI / 2 at hour 10, 1.42 at hour 12.8 and 0.48 at hour 2. Outside that it is an error in development. A deployed game draws the engine’s arc and logs why. false in an override drops a base look’s value, such as for an override that moves the hour into the night.

Unity, Godot and PlayCanvas place the sun by their directional light’s rotation and leave the time of day to a script. Unreal’s Sun Position and Roblox’s GeographicLatitude raise the arc through a latitude. A look takes the height a reference frame shows instead, and its hour keeps the day.

minSunElevationRadians and maxSunElevationRadians clamp how high the key light stands, by day and by night, so a shadow never goes flat at dawn or falls straight down at noon. The clamp is soft, blended over 0.12 radians as Luminati’s is, and the most must stand at least 0.24 over the least. It moves the light alone: the sky’s sun stays where the arc puts it.

sunShadows takes an object in place of true to set the shadow further. normalBias is three’s LightShadow.normalBias, 0.02 when left out; a low sun wants more, such as the diorama look’s 0.055. nearCascade fits the sharp near cascade to a square about the camera’s focus, in place of a slice of the view:

  • size: metres across the square’s side.
  • forwardShare: how far ahead of the focus the square stands along the view’s level heading, as a share of the camera’s distance to the focus, at most a quarter of size. A camera that looks down sees more ground past its focus than before it.

The square is as the sun sees it, so a low sun spreads it far along the ground. It snaps to its texels, so the shadow never shimmers as the camera moves, and the far cascade shadows the whole view outside it. A Landscape that sets shadowSplit beside it is an error in development. It draws the same passes as the view’s slice, and measured on the diorama’s square at the default quality on 2026-10-17, interleaved runs took 7.53 and 6.95 ms a frame with it against 7.06 and 8.22 ms without, within the runs’ noise. Unity, Unreal and Godot fit every cascade to a slice of the view; a camera that looks down from 30 m then casts its whole scene from the far cascade, as the engine’s default split of 14 m does.

The square needs the camera’s focus, which Camera2D and the follow camera name; a rig of your own names its focus with setCameraFocus. With no focus, the cascades fit the view. Under a WebGPURenderer the far cascade shadows the whole view.

Pass { base, ...values } in place of the look to replace any value of it. A value that holds settings, such as a pass or the grade, merges member by member into the base look’s, so bloom: { intensity } keeps the base’s threshold. sky, daylight and fog replace the base’s whole, since their values are chosen together. false drops the pass or the fog:

import { Landscape } from "@spawnite/engine";
import { noon } from "@spawnite/engine/looks/noon";
export function BrightNoonScene() {
return (
<Landscape
map="meadow"
look={{
base: noon,
exposure: 1.2,
bloom: { intensity: 1 },
vignette: false,
}}
/>
);
}
Value What it sets
hour The hour the Landscape opens on.
environment intensity, the light the environment lends every surface at the look’s hour; image, an image to light from in place of the engine’s sky, as Lighting from an image says, or false to drop a base look’s image.
sun The share of the rig’s sun kept: less under cloud.
daylight The day’s colours, sunColor, horizonSunColor, moonColor, nightFillColor, fillSkyColor, fillGroundColor, nightExposure and exposureAdaptation, or keyframes with their sunrise and sunset.
minSunElevationRadians The least the key light stands over the horizon, as its height and its shadow says.
maxSunElevationRadians The most the key light stands over the horizon.
sunShadows false casts no sun shadow; an object sets normalBias and a nearCascade square, as its height and its shadow says.
northOffsetRadians Turns the sun’s path about up, as Unreal’s Sun Position north offset. Positive turns it from +z toward +x, Math.PI / 2 a quarter turn, and the moon turns too. 0 keeps the engine’s path.
sunElevationRadians The sun’s height over the horizon at the look’s hour, with the day’s arc scaled through it, as The sun’s height says; false keeps the engine’s arc.
fill The share of the rig’s hemisphere fill kept beside the sky’s light.
exposure Multiplies the rig’s exposure for the hour, a keyframe’s too.
fog color, near and far in metres for three’s linear fog, an exponential fog, or false.
heightFog Haze that lies low, as Height fog says, or false. No look sets one.
depthOfField A blur off the focus and outside a band across the screen, as Depth of field says, or false. The diorama look sets one.
kuwahara A painted finish, as A painted finish says, or false. No look sets one.
postProcessing false keeps the look’s light and fog and mounts no stack, so the game can mount its own <PostProcessing>.
bloom Bloom’s props, or false.
ambientOcclusion AmbientOcclusion’s props, or false.
vignette Vignette’s props, or false.
grading hue in radians, and saturation, brightness and contrast from -1 to 1; no channel goes below zero, and 0 leaves the frame as is. tint multiplies the light first. stage says where it draws, as the grade’s stage says.
characterLight intensity, color, yawRadians and pitchRadians, or false, as Lighting characters says.
characterSilhouette The fill, the outline, the hidden share it waits for and characters, or false, as Character silhouettes says. The diorama look shows its view target’s; no other look shows one.
characterBlobShadow A soft disc under every character at every quality level, or false, as a blob shadow under characters says. No look sets one.
wind speed, directionRadians and gust, or false for still air, as Wind says. No look sets one, so every look blows the engine’s breeze.
cloudShadows speed, directionRadians, scale, darkness and coverage, or false, as Cloud shadows says. No look sets one.
wallBounce The share of the sun’s colour a BlockMap’s upright faces take, scaled by the sun’s height, as Block maps says. The diorama look sets 0.44; left out, none.

grading.stage says where the grade and the vignette draw. Every look but one grades the frame’s light before the tone mapping, GradingStage.BeforeToneMapping, and the tone mapping still takes light brighter than white. With GradingStage.AfterToneMapping the look grades the tone-mapped frame as the screen shows it, in sRGB, with the vignette after it, as Luminati and Godot grade. The look then mounts its own tone mapping before the grade. Unity calls the two stages its HDR and LDR grading modes.

A saturation or a contrast moves the same pixels further after the tone mapping than before it, so a look that changes stage retunes its grade. The engine’s saturation and contrast are adjustments about 0. A multiplier m, as Luminati’s grade gives, is a saturation of 1.001 - 1 / m and a contrast of 1 - 1 / m.

A grade at GradingStage.AfterToneMapping takes operations a grade before the tone mapping refuses, in its type and in development, since each one is defined on the screen’s colours. They apply in the following order, Luminati’s:

  1. chromaticAberration splits red from blue toward the edges, growing with the square of the distance from the centre, 0 to 0.05. sharpness, 0 to 1, sharpens the frame, with the detail it adds held within 0.08. The two draw in a pass of their own, which mounts only when the look sets one of them.
  2. postExposure brightens in stops, as Unity’s Color Adjustments’ Post Exposure does.
  3. whiteBalance.temperature warms the frame above 0 and cools it below, from -1 to 1, and whiteBalance.tint turns it toward magenta above 0 and green below. Either keeps a grey’s brightness.
  4. contrast, brightness, hue and saturation as before, with nightSaturation taking over from saturation through the night.
  5. splitToning adds shadows to the dark half of the frame and highlights to the bright half, each an offset of three channels from -1 to 1.
  6. The vignette.
  7. grain, 0 to 1, and dither, 0 to 8 levels of an 8 by 8 Bayer pattern, which breaks the bands an 8-bit screen draws in a slow gradient.

Unity grades after its tone mapping in its LDR mode, Godot after its tonemap, and Unreal’s film grain and chromatic aberration draw after its tone curve too. The live grade that useLookGrading returns holds each of these, so a game eases them as it eases the rest, as Easing the grade shows. Only the sharpness and the aberration need the look to set one of them first, because their pass mounts with the look.

The diorama’s display grade, vignette and grain took the post-processing passes from 0.45 ms of the GPU’s frame to 0.69 ms, against the same look graded before the tone mapping. The sharpness and aberration’s pass alone moved the frame by less than the runs’ noise. Measured on 2026-10-18 with spawnite play profile --gpu-passes on the diorama’s square at the golden hour, 1920 by 1080 on an RTX 3070, the median of three interleaved runs.

diorama lights a pixel diorama under Camera2D’s tilted rig: a low gold sun with long soft shadows against a violet fill, a blue night lit by the moon, fog that melts the far ground into the sky, and a warm grade after ACES. Its values are Luminati’s, read from its deployed build on 2026-10-17, except where the look’s shots measured short of Luminati’s frames, as the following table lists:

Value Diorama Luminati The engine’s own
Day 13 keyframes, sunrise 6 and sunset 19.2 13 keys and its game’s overrides on 6 of them the arc, sunrise 0 and sunset 20
Golden hour, 17.2 sun #ffb466 at 6, fill #7a7cc8 over #7a6058 at 1.8, exposure 1.12 fill #6a80d4 at 1.45, the rest the same sun at 2 and fill at 1.2 at their peak
Midday, 12.2 sun #ffd9a6 at 6, fill #b4c0e4 at 1.5, exposure 1.26, and 6 at exposure 1.15 at 15.3 sun #fff4e2 at 3.5 and 3.6, exposure 1 sun at 2
Night moon #6080ff at 1, fill #3656c0 over #1a2042 at 1.6, exposure 1.36 moon #7294ff, the rest the same exposure a quarter of the day’s
Key light’s height 34 to 68 degrees, soft, so 35 at 17.2 10 to 68 degrees, soft, so 25 at 17.2 0 to 55 degrees
Sun’s bearing at 17.2 -112 degrees from the camera’s side, northOffsetRadians 1.92 -112 degrees 138 degrees
Shadow near square of 52 m pushed 0.22 ahead, normal bias 0.055, radius 2.5 by day and 3.2 at night the same, on a 2048 map cascades split at 14 m, bias 0.02, radius 2
Fog exponential, from 7 m short of the focus, each keyframe’s density times 2, thinning past 30 m the same none, or linear from 8 to 10 m
Grade after tone mapping: exposure 1.03, white balance 0.04 warm, contrast 1.04, saturation 1.3 falling to 1.08 at night, split toning, sharpness 0.15, aberration 0.0015, grain 0.03, dither 1 the same, as multipliers before tone mapping
Bloom strength 0.507, radius 0.58, threshold 1.05 on the brightest channel, knee 0.35, capped at 24, wider levels tinted warmer strength 0.5 and warmth 0.25, the rest the same per look
Vignette offset 0.43, darkness 0.45, roundness 0.65, toward #0d060a 0.55 with a softness of 0.55, toward a warm brown per look, round and black
Sky the pixel sky, a sea of clouds at 0.25 the same the scattering sky
God rays gain 0.17, fading in over 3.5 m above the foot, the rest the engine’s settings gain 0.2, fading over 2.2 m the same in every look
Depth of field defaultDepthOfField: focused on the camera’s focus, sharp 3 m either side, 0.012 of the short side, a band of 0.3 with a floor of 0.42, discs past 1.5 the same, focused 0.9 m up from the player none
Silhouette the view target’s, #d9ccff at 0.55 shaded by the sprite’s own pixels, a 1-pixel #241820 outline, from a quarter hidden, as Character silhouettes says the player’s x-ray behind a roof, pale lilac none
Sky light, character light, occlusion off none per look

The lamps join the look in the layer that builds them. Luminati’s warmth of 0.25 tints each wider level of its bloom toward amber; the diorama gives that as tint and wideTint with red at 1, and folds the 1.4 percent left over into the intensity. A Landscape under it sets bounceLight={false}, as Luminati’s light takes nothing off the ground.

wind is the wind the grass bends in, one wind for the whole scene, as Unity’s WindZone and Roblox’s GlobalWind give a scene one. Every engine shader that moves in the wind samples it at its own place, so a gust that crosses the grass crosses the foliage with it.

  • speed: metres a second it blows at its mean, such as 3 for a light breeze and 8 for a fresh one.
  • directionRadians: the direction it blows toward, downwind, turned from +z toward +x as northOffsetRadians turns the sun. 0 blows along +z, and Math.PI / 2 along +x. A wind from the north, out of -z, blows toward +z, so it is 0.
  • gust: how much gusts swing its speed, and the plants’ sway with it, from 0 to 1. Gust fronts about 30 m across roll down the wind over ground that is mostly in a lull, so a gust arrives at one tree and then the next. 0 is steady. At 0.5 a lull blows half the mean and a gust’s heart about 2.4 times it; at 1 a lull is still air and a gust’s heart 3.7 times the mean. The mean over the map stays speed.

Left out, the engine blows a light breeze: 3 m/s toward 1.2 radians with a gust of 0.5. false is still air. A partial wind over a base look keeps the rest of the base’s wind, or of the engine’s breeze where the base sets none, so wind: { speed: 9 } over overcast keeps the breeze’s direction. The engine’s tests mount this file:

packages/engine/test/outside/StormScene.tsx
import { Landscape } from "@spawnite/engine";
import { overcast } from "@spawnite/engine/looks/overcast";
// An overcast meadow in a strong, gusting wind: the grass leans hard and
// gusts roll across it. The wind keeps overcast's direction from the
// engine's breeze.
export function StormScene() {
return (
<Landscape
map="meadow"
look={{ base: overcast, wind: { speed: 9, gust: 0.9 } }}
/>
);
}

A Landscape writes its look’s wind with or without its lighting, so lighting={false} keeps the grass moving. Inside a Landscape, its own look’s wind blows; a <Lighting> with no Landscape around it writes its own. Each canvas has one wind, and where two Landscapes share a canvas the one that mounted last blows it. Landscape’s Grass says when the grass moves and which clock the wind blows on.

The wind is drawn only: a room holds no look, so gameplay that needs the wind, such as a sail or an arrow’s drift, reads its own value in the step. Unreal’s WindDirectionalSource drives only its SpeedTree assets, and its SimpleGrassWind material function takes no direction, so the one wind every engine shader reads is this engine’s own. A value out of range, a negative speed or a gust outside 0 to 1, is an error in development; a deployed game blows still air and logs why.

A look’s fog takes three’s exponential FogExp2 beside its linear Fog. It thickens with distance, and starts back from the camera’s focus:

  • color and density, as three’s FogExp2 takes them. Keyframes give both, so a keyframed look leaves them out.
  • startBeforeFocus: metres short of the focus’s depth where the fog starts. 7 puts 7 m of fog before the focus at every zoom; a negative number starts it past the focus.
  • referenceDistance: the camera’s distance to its focus that the density holds at. Farther out it thins, to 0.4 of it at least, so a zoom out draws no thicker frame. Left out, the density holds at every distance.

Unreal’s height fog, Godot’s depth fog and Roblox’s FogStart start their fog at a distance from the camera. A camera that zooms then moves its focus through the fog, so this one starts back from the focus, as Luminati’s does. Camera2D and the follow camera name their focus, and a rig of your own names its focus with setCameraFocus; with none, the fog starts at the camera, and a development build says so.

The start reaches every material of a Landscape’s scene that takes the fog, lit or unlit, through the scene’s light terms. A shader of your own that fogs takes the fog from the camera. Under a WebGPURenderer the fog starts at the camera.

cloudShadows lays soft shadows of clouds over the ground from straight above, and drifts them, as pixel games draw clouds passing over their grass. Every sprite and tile layer takes the shade at its own place, so a skeleton that walks under a cloud greys with the grass round it. An additive sprite, a glow, gives light and takes none, and so does an unlit material of your own, such as a ParallaxLayer’s sky drawn with meshBasicMaterial. A lit material dims under it wherever it stands, a backdrop’s too. A lit material dims the rig’s sun and moon by the shade and keeps its fill, its glow and every other light, a directional light of your own among them, as the light mask does. A 3D game under Camera2D turns it on the same way. It has five values:

  • speed: metres a second the shadows drift, 1.5 when left out.
  • directionRadians: the direction they drift toward, turned from +z toward +x as the wind’s is. 0 drifts along +z, and Math.PI / 2 along +x. It is the shadows’ own, not the wind’s, since the wind a cloud rides is not the grass’s; 1.2 when left out, the engine’s breeze.
  • scale: metres across one cell of the field, about one cloud’s shadow at the middle coverage, 8 when left out. 8 m is 128 pixels of art at 16 pixels a metre.
  • darkness: the share of the light the heart of a shadow takes, from 0 to 1, in light before the tone map, 0.75 when left out. At 0.75 a shadowed pixel keeps about half its lit colour on the screen.
  • coverage: how much of the ground lies under cloud, from 0, a clear sky, to 1, overcast, 0.35 when left out. It moves a threshold over the field, so it reads as a share without being one exactly. 0 draws none.

No look sets one. A partial cloudShadows fills the rest from the engine’s values above, so cloudShadows: { coverage: 0.5 } keeps their darkness and size. Pass the look to Lighting or Landscape; the engine’s tests mount this one in a Lighting:

packages/engine/test/outside/cloudyPixel.ts
import type { LookPick } from "@spawnite/engine";
import { pixel } from "@spawnite/engine/looks/pixel";
// A 2D game's light with cloud shadows: half the ground under cloud,
// drifting along +x, and the engine's darkness and size for the rest.
export const cloudyPixel = {
base: pixel,
cloudShadows: { coverage: 0.5, directionRadians: Math.PI / 2 },
} satisfies LookPick;

The shade is a field of noise of its own, not the sky’s clouds, and it projects straight down whatever the sun’s angle. On a side-scroller’s plane it falls straight down too, so each cloud shades a column from the ground up, as sunlight does. It drifts on the effects’ clock, so a pause holds it, and each canvas draws one field, written by the Landscape or the <Lighting> that writes the wind. Under WebGPU none draws, and the console says so once. A value out of range, a darkness or coverage outside 0 to 1, a scale of 0 or less or a negative speed, is an error in development; a deployed game draws no shadow and logs why.

Unreal casts its volumetric clouds’ shadow through the directional light’s Cast Cloud Shadows and Cloud Shadow Strength. Unity HDRP’s Cloud Layer projects a shadow cookie from its clouds, off unless Cast Shadows is set, with a Shadow Multiplier of 1 and a black Shadow Tint. URP has no cloud shadow setting, though a game can pan a cookie on its main light. The documentation of Unity’s 2D renderer, Godot, Roblox and PlayCanvas names no cloud shadow setting, so a 2D game there multiplies a sprite over the ground. The defaults are measured from a shipped pixel game’s frames, not taken from an engine.

It costs about 0.024 ms a megapixel drawn, measured alone on an RTX 3070 card. That is about 0.006 ms for a pixel-perfect frame’s 640 by 360 target and 0.05 ms for a smooth 2D game at 1080p, times the layers drawn over each other. A phone’s GPU is about 20 to 40 times slower, an estimate, so the smooth 1080p case costs it about 1 to 2 ms of frame time. Off, it costs one test of a uniform a pixel, and turning it on compiles no shader for a sprite or a tile. A lit scene with nothing else of the light mask’s kind compiles its lit materials once more.

GodRays stands shafts of sunlight over an area of the scene, as the beams through a village’s haze in a diorama: soft additive strips leaning toward the sun. Mount one where the light should show, with the area’s size in metres and a position. It lays one shaft to every 90 square metres, from 1 to 6, unless count says otherwise, and seed picks another layout. A shaft draws in the key light’s colour, fades within a few metres of the camera, over its foot, in fog, as the sun sinks to the horizon and at night. It is strongest through the golden hour and after sunrise.

The look’s godRays sets how every area draws its shafts: intensity, tint, steepness and the fades. Left out, the engine’s settings draw them, which are Luminati’s. godRays: false draws none anywhere, and a development build says so once for a scene that mounts an area under it. Unity and Godot leave shafts like these to a mesh with an additive material, and Unreal draws light shafts from the sun as a screen pass; these are a mesh, so a game places them where its art wants them.

The look’s rain and snow set how the rain and the snow fall while the world’s weather rains or snows, Luminati’s unless set, and false draws none. Its snowCover sets the colour lying snow takes, and snowCover: false lays none.

The square’s four shafts took the GPU’s scene pass from 0.92 ms to 1.03 ms. Measured on 2026-10-18 with spawnite play profile --gpu-passes on the diorama’s square at the golden hour, 1920 by 1080 on an RTX 3070, the median of three interleaved runs.

heightFog lays haze in the low ground, as Unreal’s Exponential Height Fog does: thick at height and below, thinning upward, and summed along the eye’s ray to each point. It fills a valley and the gaps between far trees, and thins over the ridges, where the look’s fog thickens evenly with distance alone. Its values are the following:

  • color: the haze’s colour.
  • density: how much of the light a metre of fog at height takes, such as 0.01 for a light haze and 0.05 for a mist.
  • height: metres above the map’s zero where the fog has its density.
  • falloff: how fast it thins upward. The density halves every 0.69 / falloff metres, so 0.1 halves it every 7 m.
  • start: metres from the camera before the fog begins, as Unreal’s start distance, so the nearest ground stays clear; 0 when left out.
  • sunScatter: how much of the sun’s light the fog scatters toward the eye at its thickest, 0 to 1, as Godot’s fog_sun_scatter: a warm glow in the haze around the sun; 0 when left out.
  • sunScatterExponent: how tight that glow is, as Unreal’s DirectionalInscatteringExponent. A larger number draws a smaller glow; 8 when left out.
  • maxOpacity: the most of a pixel the fog may hide, 0 to 1, as Unreal’s FogMaxOpacity; 1 when left out.
  • skyDistance: metres the sky stands at for the fog, so the haze lies over the sky’s horizon as over ground that far, and thins up the sky. Left out, the sky takes no fog.
  • farColor and farDistance: the colour the fog turns toward with distance, and the metres from the camera where it is wholly that colour, turning from color at start. Far air takes the sky’s colour, so a valley’s far ridges read blue while the near air keeps a neutral color. Set both or neither; farDistance lies past start.

Pick farColor as the drawn sky’s colour at the horizon before the look’s exposure and grade, since the fog draws before them. For a painted sky that is the image’s horizon times its intensity. Keep farDistance at or under skyDistance where both are set, so the sky’s haze is as far turned as a ridge in front of it. The far colour is one colour in every direction and at every hour: it dims with the light, as color does, and the sun’s glow still warms the side toward the sun. Godot’s fog_aerial_perspective and HDRP’s Sky Color mode read the sky’s cubemap along each ray instead, and Unreal’s Inscattering Texture a cubemap of its own. Here the scene’s environment is a bake for light, clipped and fixed at the look’s hour, which a far ridge would show.

The glow takes the sun itself, not the key light: it reddens as the sun sets, fades through the twilight, and takes no moon. It is an artistic lobe with no shadowing, as Unreal’s and Filament’s analytic fog draw theirs, so a ridge in front of the sun still glows. Set skyDistance past the farthest ground the scene draws, or a far ridge takes more haze than the sky behind it. The fog’s colour dims with the light on the ground, as the plain fog’s does.

It reads the frame’s depth, so it draws with the look’s grade, at Medium and High. Wherever it does not draw, the look’s fog stands in for it: at Low and Minimum, under WebGPU, beside a scene’s own stack, and with postProcessing: false. Wherever it draws, the rig leaves the plain fog out, so a look sets both and the two never stack. A value out of range is an error in development; a deployed game draws the plain fog instead and logs why. Last Light’s forest edge, games/last-light/src/scenes/ForestEdge.tsx, sets a valley haze with a sun glow.

depthOfField keeps a band of depth around the camera’s focus sharp, blurs what stands before and past it, and floors the blur above and below a band across the screen, so the frame reads as a photograph of a model. A bright speck off the focus draws as a soft disc of its blur’s size. Its values are the following:

  • focus: what stays sharp. DepthOfFieldFocus.CameraFocus reads the point setCameraFocus names, which Camera2D and the follow camera name for you; a number is metres of view depth along the camera’s forward axis. With CameraFocus and no focus named, as under a free camera, the band alone blurs.
  • focusDampingSeconds: seconds the focus takes to close most of the way to a new depth, as Camera2D’s dampingSeconds. 0 follows at once, and a jump of twice focusRange, such as a teleport, snaps.
  • focusRange: metres of view depth that stay sharp, half of it either side of the focus. Past it the blur grows to its full circle over 1.5 times the range.
  • radius: the circle of confusion’s radius at full blur, as a share of the screen’s short side, so a portrait phone blurs a sprite as much as a landscape screen does. 0.012 is about 13 pixels at 1080p.
  • nearScale and farScale: the near and far sides’ circles against radius, 0 to 3. 0 turns a side’s depth blur off.
  • tiltShift: the band, or false for depth alone. strength is the floor on the blur outside the band against radius. center is the band’s middle as a share of the screen’s height from its bottom, and height its full extent. feather is the share over which the floor ramps in past each edge; 0 is a hard edge.
  • bokeh: the discs, or false for the blur alone. threshold is the luminance a speck must pass after the look’s exposure, where 1 is white, and boost the disc’s light against the speck’s, 0 to 4.

The circle is the larger of the depth’s and the band’s, signed by its side of the focus: inside the band the depth still blurs, and outside it a pixel at the focus still blurs. An override over a base with no depth of field starts from defaultDepthOfField, Luminati’s values, which the diorama look takes whole; its tiltShift and bokeh replace whole. Unity and Godot set near and far distances in metres, PlayCanvas a focusDistance and a focusRange, and Roblox a FocusDistance and an InFocusRadius. None of them floors the blur by the screen’s rows.

It is its own pass after the height fog and before the bloom, in the frame’s light, so the bloom reads its discs. At half resolution it gathers a golden-angle disc of 48 or 64 taps into a near and a far layer, smooths them with a tent, and draws each bright speck as one rimmed disc. A full-resolution composite then keeps a pixel whose circle is under 0.3 of a pixel exactly as drawn, and blends from a small full-resolution disc to the half-resolution layers, so the falloff never steps. A disc never draws over a sharp surface in front of it.

It reads the frame’s depth. A surface that writes no depth, such as an additive particle, takes the depth of what stands behind it, which is what turns a firefly past the focus into a disc. The light past a disc’s threshold leaves the blur and draws as the disc, so a speck’s light counts once.

The quality level’s depthOfField says what draws:

  • full, at High: the band, the depth, the near layer and the discs.
  • reduced, at Medium: the band and the depth in one layer, with no discs. The near field blurs in place and never over what stands behind it.
  • off, at Low and Minimum.

The Post-processing row of the Graphics settings pins it with the grade and the bloom. The player’s Depth of field setting turns it off at every level, as an accessibility setting a game cannot take away, or on as reduced at a level that draws none.

The stack’s devtools tree shows a Depth of field leaf whose debug view draws the circle in place of the blur: the near side orange, the far side blue, and the sharp band green. A value out of range is an error in development, naming the field; a deployed game draws no blur and logs why. A game with its own <PostProcessing> stack draws no depth of field from the look.

At High it costs about 0.65 ms of a 1080p frame on an RTX 3070, measured on and off, interleaved, from the start camera of the diorama game’s square; the pass’s own span is 0.56 ms. At Medium the reduced pass takes about 0.41 ms.

kuwahara gives the frame a painted finish with a Kuwahara filter. Each pixel takes the mean of the calmest of eight sectors around it, bent along the local edge. Fine detail, such as single grass blades and the edges of needle cards, flattens into short strokes that run along the edges, and the edges themselves stay. It has one value:

  • radius: the filter’s reach, as a share of the screen’s height, from 0 to 0.005. 0.002 is about 2 pixels at 1080p, a painted softness; past about 0.003 the near grass smears. It holds across resolutions and pixel ratios, and moves smoothly between whole pixels.

It draws first in the look’s stack, and the haze lies over it. With a depth of field, the blur and the bloom read the painted frame; without one, the bloom reads the frame as drawn. It draws with the look’s grade, at Medium and High; at Low and Minimum nothing is painted. A value out of range is an error in development; a deployed game draws no filter and logs why.

It costs about 0.5 ms a frame at 1080p on an RTX 4070 SUPER at 0.002, measured on and off from one camera in the forest edge at High. Its reads a pixel grow with its reach in pixels, up to twelve rings, so 0.002 at 4K reads about 1.6 times as much a pixel, over four times the pixels. Turning it on compiles one more shader program. At 2 pixels a far character’s face loses its detail, and so do ropes, small particles and text drawn in the world.

A light mask darkens regions of the world: the dark side of a map, the shade under a canopy, or a night where only the lantern circles are lit. It is a texture laid over the ground from above, handed to Landscape or Lighting as lightMask. Its red channel is the share of light at each spot: 1 is lit as the look lights it, and 0 is the dark that the mask’s values set. Between them, every value blends evenly, so a grey ring is a soft edge. With a boundary, red holds the distance to a sharp line instead.

Where the mask is dark, it dims the following:

  • The sun, and the moon after dark, all of it unless sun keeps a share, and by region where a sunMap says.
  • The sky’s fill, by fill: the hemisphere light, the environment’s light and reflections, any ambient light, light probe or light map, and the look’s character light.
  • The fog, by fog: the height fog’s colour and density, and the plain fog’s colour.

A light of your own, such as a lantern’s local light, keeps its light inside the dark unless the mask’s localLights say otherwise, and a glowing surface keeps its glow. A glow sprite keeps a small glowing point in sight from far, such as a lantern seen from a lookout. The mask’s values are the following:

  • texture: the mask, written as the game runs.
  • size: the metres it spans along x and along z, as [x, z].
  • center: the point on the ground under its middle, [0, 0] when left out. Past its edge, the edge’s value holds.
  • fill: the share of the sky’s fill kept where the mask is 0, from 0 to 1. 1, the default, leaves the fill alone; 0.25 is a region in deep shade.
  • sun: the share of the sun’s light kept where the mask is 0, from 0 to 1, with its shadows. It reaches every directional light, the rig’s sun and moon and any of your own. 0, the default, leaves the dark unlit by them. A moonlit night outside lamp pools keeps all of it, so the woodland takes the moon while the pool’s line stays the step from litSun to it.
  • litSun: the share of the sun’s light kept where the mask is 1, the lit land, from 0 to 1, as sun is for the dark. 1, the default, lights the lit land as the look lights it. At night, where the lit land is a lamp’s pool, about 0.3 lets the pool outshine the moon, as an eye used to the lamp sees it: with the moon whole inside, a warm pool reads olive or cream. Every spot red counts as lit takes it, a day’s circle as much as a pool, so a mask kept by day sets it back to 1 for the day. Unity’s cookie and Unreal’s light function set the share at each spot from a texture or a material; here red is a distance under a boundary, so the shares at its two ends are values, and a sunMap scales both by region.
  • sunMap: a cookie for the sun, a texture whose red multiplies the share sun and litSun keep, by region, as the sun by region says.
  • fog: tint, a colour that multiplies the fog’s where the mask is 0, as the grade’s tint multiplies the frame; and density, a factor on the fog’s thickness there, such as 3 for thicker air, the height fog’s and the plain fog’s alike.
  • boundary, fillLight, groundFog and localLights: a sharp line between the light and the dark, the lit land’s own light, the dark as a body on the ground, and a lamp’s light past the line, as the sections below say.

The engine’s tests run this file, which lights a circle round each lantern on a dark noon meadow:

packages/engine/test/outside/LanternScene.tsx
import { useEffect, useLayoutEffect, useMemo } from "react";
import { DataTexture, LinearFilter, RedFormat } from "three";
import { Landscape, type LightMaskOptions } from "@spawnite/engine";
import { noon } from "@spawnite/engine/looks/noon";
/** A lantern's place on the ground and the radius of the circle it claims,
* in metres. */
export interface Lantern {
x: number;
z: number;
radius: number;
}
/** Metres the mask spans along x and along z, centred on the map. */
const maskSize = 200;
/** Texels along each side: under a metre a texel. */
const maskTexels = 256;
/** The mask's texture: one red byte a texel, filtered smoothly so a
* circle's rim is a ramp, not a stair of texels. */
export function createLanternMask(): DataTexture {
const texture = new DataTexture(
new Uint8Array(maskTexels * maskTexels),
maskTexels,
maskTexels,
RedFormat,
);
texture.magFilter = LinearFilter;
texture.minFilter = LinearFilter;
return texture;
}
/** Lights each lantern's circle, with a 2 m soft step at its radius, and
* leaves the rest dark. The first texel is the mask's -x, -z corner; its
* rows run along +z. */
export function paintLanterns(
texture: DataTexture,
lanterns: readonly Lantern[],
) {
const data = texture.image.data as Uint8Array;
for (let row = 0; row < maskTexels; row++)
for (let column = 0; column < maskTexels; column++) {
const x = ((column + 0.5) / maskTexels - 0.5) * maskSize;
const z = ((row + 0.5) / maskTexels - 0.5) * maskSize;
let light = 0;
for (const lantern of lanterns) {
const away = Math.hypot(x - lantern.x, z - lantern.z);
const share = (lantern.radius + 1 - away) / 2;
light = Math.max(light, Math.min(Math.max(share, 0), 1));
}
data[row * maskTexels + column] = Math.round(light * 255);
}
texture.needsUpdate = true;
}
/** The dark side of the world at noon, with a lit circle round each lantern:
* the sun, the sky's fill and the haze all darken outside the circles. */
export function LanternScene({ lanterns }: { lanterns: readonly Lantern[] }) {
const texture = useMemo(() => createLanternMask(), []);
// Before the first frame draws, and again as the lanterns change.
useLayoutEffect(
() => paintLanterns(texture, lanterns),
[texture, lanterns],
);
useEffect(() => () => texture.dispose(), [texture]);
const lightMask: LightMaskOptions = {
texture,
size: [maskSize, maskSize],
fill: 0.25,
fog: { tint: "#33405a", density: 3 },
};
return <Landscape map="meadow" look={noon} lightMask={lightMask} />;
}

The texture’s u runs along +x and its v along +z. In a DataTexture, the first texel is the -x, -z corner, its columns run along +x and its rows along +z. A CanvasTexture reads the same, its top row along -z, whichever way its flipY is set. Write the texture, then set its needsUpdate; until its first update the mask draws nothing, and a development build says so after a second. Keep its colorSpace as NoColorSpace, so the shares read as written: an sRGB texture is an error in development. Give a DataTexture a LinearFilter, or a circle’s rim steps from texel to texel.

Write the texture again whenever the regions change, such as when a lantern is lit. A 256 by 256 mask is 64 KB to upload. Changing the mask’s other values costs nothing.

sun and litSun are one share each for the whole mask. To keep the moon in a wood and put it out in the rim past it, give the mask a sunMap: a cookie, as Unity’s light cookie and Unreal’s light function are, laid over the mask’s own size and center. Its red multiplies the share of the sun’s light that sun and litSun keep at each spot, with its shadows: 1 keeps the share, and 0 puts the sun out there.

The map scales the lit land and the dark alike, so a lamp’s pool in a moonless rim keeps no moon unless the map keeps it there. It reaches what sun reaches: every directional light, the sun under a canopy, the light off the ground and the height fog’s glow toward the sun.

A map only takes light away. To keep the moon in part of the dark, set sun to the share the brightest region keeps, such as 1, and paint the map lower where less is kept. With the default sun of 0, the dark keeps none to scale. Only red is read, its edge’s value holds past it, and its colour space stays NoColorSpace. Give a DataTexture a LinearFilter, or a region’s edge steps from texel to texel, as a tile map’s may want.

The engine’s tests run this file, which keeps the moon in a wood 300 m across the mask’s middle and puts it out past it:

packages/engine/test/outside/moonlitWood.ts
import { DataTexture, LinearFilter, RedFormat, type Texture } from "three";
import type { LightMaskOptions } from "@spawnite/engine";
/** Metres the mask and its sun map span along x and along z. */
export const woodMaskSize = 1024;
/** Texels along each side of the sun map: 4 m a texel. */
const sunTexels = 256;
/** Metres the moon fades over at the wood's edge: two texels. */
const edgeWidth = 8;
/** A sun map that keeps the whole moon within `radius` metres of the
* mask's middle and none past it, over a soft edge. The first texel is the
* -x, -z corner; its rows run along +z, as the mask's do. */
export function createMoonlitWood(radius: number): DataTexture {
const data = new Uint8Array(sunTexels * sunTexels);
for (let row = 0; row < sunTexels; row++)
for (let column = 0; column < sunTexels; column++) {
const x = ((column + 0.5) / sunTexels - 0.5) * woodMaskSize;
const z = ((row + 0.5) / sunTexels - 0.5) * woodMaskSize;
const kept =
(radius + edgeWidth / 2 - Math.hypot(x, z)) / edgeWidth;
data[row * sunTexels + column] = Math.round(
Math.min(Math.max(kept, 0), 1) * 255,
);
}
const sunMap = new DataTexture(data, sunTexels, sunTexels, RedFormat);
// Filtered, so the edge is a ramp rather than 4 m squares.
sunMap.magFilter = LinearFilter;
sunMap.minFilter = LinearFilter;
sunMap.needsUpdate = true;
return sunMap;
}
/** A night's mask over lamp pools: the wood keeps the whole moon, the rim
* past it none, and a pool a third of what its ground keeps. */
export const createMoonlitWoodMask = (
texture: Texture,
sunMap: Texture,
): LightMaskOptions => ({
texture,
size: [woodMaskSize, woodMaskSize],
sun: 1,
litSun: 0.3,
sunMap,
});

Until the map holds data, the sun keeps its shares everywhere, and a development build says so after a second. Setting a map on a scene that had none compiles each lit material once more: with the rest under the loading screen, and after it ahead of the frame it lands in, where the browser compiles in parallel. Dropping it compiles nothing: the materials keep the term and read a white texel.

A line the player stands on either side of

Section titled “A line the player stands on either side of”

Give the mask a boundary, and its red channel holds the distance to the line between its light and its dark rather than a share, so the player sees at a glance which side of the line they stand on. The lit materials then draw the line as sharp as you ask, at every quality level, with no post-processing.

Write red as 0.5 + distance / rampWidth, clamped from 0 to 1, with the distance in metres and positive in the light. Red 0.5 is the line. Join two shapes by keeping the larger red, as a max blend does, and use one rampWidth for the whole texture, so the larger red is always the nearer light. The filter finds the 0.5 crossing between texels, so a ramp of two texels or more places the line to under a centimetre on a circle. In 8 bits, each step of red is rampWidth / 255, 6 mm for a 1.6 m ramp; a HalfFloatType render target is finer. The engine’s tests measure the following limits at 0.4 m a texel:

  • Where two circles meet, the filter rounds the notch between their rims by up to 9 cm.
  • A gap between two lit shapes narrower than a texel closes.
  • A lit island about a texel across comes out rounder, its line up to 14 cm off.

The texture is a picture of the game’s own answer to “is this point in the light”, and never its source. The room’s check and the drawn line both come from one function, as readLanternDistance is below. Give the texture a LinearFilter for both its magFilter and its minFilter, so no mipmap averages the line from far: anything else is an error in development. Size the texture to cover the map, and pad the shapes so they close before its edge, since past its edge the edge’s value holds. A scene takes one mask: draw every region into its texture, since a second lightMask in one scene is an error.

The boundary takes the following values:

  • rampWidth: the metres red spans from 0 to 1 across the line, the ramp you write. It is required.
  • blendWidth: the metres the drawn change from lit to dark spans, centred on the line, 0.3 when left out. Far from the camera it widens to one pixel, so the line never breaks into stairs. It is at most rampWidth, since past the ramp red stops changing.
  • band: a band of extra dark and thicker air along the dark side of the line. width is the metres it reaches into the dark, at most half the rampWidth, since red stops changing there. darkness is the most of the light left on the dark side that the band takes away, from 0 to 1, 0.5 when left out. 0.6 takes 30% at the line, where the blend is half lit, and 60% just past the blend, fading to none at the width. fogDensity is the most the band multiplies the fog’s thickness by, 1 when left out: 2 thickens it 1.5 times at the line and twice just past the blend. height is the metres above the ground at which it has faded to none, measured above the Landscape’s ground, or above y 0 with no Landscape. Left out, the band reaches all the way up.
  • rim: a thin line of light on the lit side, drawn on the Landscape’s ground alone, never on a character or a prop. It takes color, intensity as an emissive surface’s, 0.5 when left out, and width, the metres it reaches into the light, 0.25 when left out and at most half the rampWidth.
  • curtain: soft strips of dark air standing on the line, as the next section says.

The region’s own dark stays full height: the band fades with height, and the sun stays off a trunk’s whole length on the dark side, or keeps only the mask’s sun share there. Unity’s Local Volumetric Fog fades a volume over its Blend Distance, Unreal’s Local Fog Volume by a radial falloff and a height falloff, and Godot’s FogVolume by edge_fade and height_falloff. Each softens the edge of a box of fog, and none draws a line that holds at the lowest quality or dims a region’s sunlight.

Give the boundary a curtain, and the engine stands soft strips of dark air on the line, rising from the ground and fraying into wisps, so the line has a body a player sees from far. An empty object, curtain: {}, turns it on with its defaults. The engine places the strips on the GPU from the mask itself each frame, so the curtain follows whatever you write into the texture, with no code of yours.

The strips lean and stretch as the line moves. The engine keeps last frame’s mask and reads from the change how fast the line crosses each place, so a dark that pours across the land, a lit pocket pushed open and a circle stepping outward all move the curtain with nothing but the mask. The change says how fast the line moves across itself and never along itself, so motion along the line, such as a wind, is yours to give in velocity. The strips’ tops lead the motion, the line’s own and velocity added, by the distance it covers in 0.35 s, at most 80% of their height.

The engine reads the change at up to 512 by 512 places over the mask, smoothed over 0.1 s. At one place, a change faster than 30 m a second is a cut rather than motion, such as a shape the game draws in at once, and the curtain there stands straight. A growth that eases in moves fastest at its start, well above its average speed.

The curtain takes the following values:

  • height: the metres the strips rise above the ground at their tallest while the line stands still, 2.5 when left out. Motion stretches them, the line’s own and velocity alike, by up to 60% at 3 m a second, so a steady velocity makes every strip taller. The tall wisps also rise and fall slowly on their own.
  • spacing: the metres between the strips’ joins along the line at most, 1 when left out. The strips are one unbroken wall, and the quality level thins the tall wisps above its base, never the wall. A lit shape smaller than the spacing may stand none, and a sharp corner is cut by a strip’s chord, by up to a quarter of the spacing where two circles meet.
  • color: the dark air’s colour, drawn unlit under the scene’s fog, a blue black, #0d1220, when left out. A colour a little lighter than the dark land reads as a wall of mist; one as dark as the land shows only against the light.
  • opacity: the most of what lies behind it the curtain hides, at its densest, just above its foot, from 0 to 1, 0.9 when left out. Over sunlit land, which the frame holds far brighter than the curtain, it takes most of that to dim the land behind it.
  • noise: size, the metres across one wisp, 1.5 when left out, and velocity, the metres a second the wisps drift along x, y and z, [0, 0.35, 0] when left out, a slow rise.
  • near: the metres from the camera inside which the curtain fades out, so a player crossing the line walks through air rather than a card, 3 when left out: none of it at half this, all of it from this out.
  • far: the metres from the camera past which none is drawn, fading over its last quarter, 60 when left out. It is the straight distance from the camera, its height included. The quality level’s curtainFar caps it, from 20 m at Minimum to 60 m at High, and the ground’s line carries the boundary beyond. A game that wants more raises curtainFar in its quality levels.
  • velocity: the metres a second along x and z the strips lean with, added to the line’s own motion, [0, 0] when left out.

The strips stand on the Landscape’s ground, read from a height map at a metre a texel, and on y 0 with no Landscape. Their feet reach below the ground and fade in over the lowest 20 cm, so no strip shows a hard edge where it meets the ground. They do not read the scene’s depth: no level’s stack hands depth to a draw inside the scene’s own pass. The strips stand upright, built for a camera near the ground: from straight above they are edge-on, and the ground’s line carries the boundary.

Every level draws the curtain, since it says where the line is: the quality levels set curtainShare, the share of the tall wisps that rise, and curtainFar. Minimum keeps the base along the line, half the height tall, out to 20 m. Unity’s and Unreal’s fog volumes and Godot’s FogVolume fill a box of fog, and a game that wants a wall along a line places cards along it itself. The curtain is placed from the mask, so the line you write is the line it stands on.

Give the mask a groundFog, and the dark’s air lies on the ground over the mask’s dark as a body with a top, such as a night that lies like smoke, a fog of war or a toxic marsh. The top follows the ground at a height you set, and the body stops at the mask’s line, where the boundary draws it. A character inside it is hidden as the fog’s density says, and trunks and characters stand out of its top.

It takes the following values:

  • height: the metres above the ground its top stands, 1.2 when left out. A standing character’s head and shoulders stay above that, and a crouched one is inside it.
  • density: how much of the light a metre of it takes, as an extinction, 0.3 when left out. exp(-density * metres) gets through, so 0.3 hides about four fifths of what stands 5 m inside it. Three.js’s FogExp2 squares the product, so its density reads differently.
  • color: its own colour where it hides all, drawn unlit as the curtain’s is, the curtain’s blue black #0d1220 when left out. A colour a step lighter than the unlit ground under it reads as a body; one darker reads as a hole.
  • albedo: the share of the mask’s fill light it scatters, black when left out. With it, a lamp’s pool lights the fog’s face along the pool’s line, over its first metre or two.
  • topBlendWidth: the metres over which its top thins from full to none, a tenth of height when left out.
  • topColor: its colour at its top, painted and unlit as color is, such as moonlight on the top of a smoke. Left out, it is one colour all through. A view across the top crosses more of it than a view down into it, so the body brightens with distance and its face toward a lamp takes a pale rim. It takes no light of the scene’s, so a sky that changes its hour wants a colour for each hour.
  • topColorDepth: the metres under the top over which topColor turns to color at a steady rate, a third of height when left out. Past height, the ground never reaches color, which a fog rising from nothing passes through. Giving it with no topColor is an error in development.
  • noise: slow swells in its top, none when left out. amplitude is the metres it rises and falls each way, at most the height less half the topBlendWidth. size is the metres across one swell, 6 when left out, and velocity the metres a second the swells drift along x and z.

It draws in a pass of its own in the look’s post-processing, before the look’s height fog, so the haze lies over a far body of it. The pass reads each pixel’s depth and sums the fog along the eye’s ray, so a trunk inside it is hidden by the air in front of it alone. The look’s stack mounts for it at every quality level, Low and Minimum among them, because a body that can hide a character must hide as much on every device. A level changes only how many reads each ray takes, from 6 at Minimum to 16 at High, never how much the fog hides. A scene that mounts its own <PostProcessing> puts <GroundFog /> inside it, before the passes that read the drawn frame; without it the ground fog draws nowhere, and a development build says so.

The top follows the first Landscape’s ground, read from the same height map as the curtain, a metre a texel or coarser on a map over 256 m across. With no Landscape it lies above y 0, and a development build says so. Transparent draws, such as the curtain’s strips, particles and water, write no depth, so the ground fog lies over them as over what is behind them. Its top follows the ground, so a level pool of fog over uneven land, a flooded basin, needs a world height that it does not take yet, and a ground fog with no mask does not exist yet either.

Unreal’s Local Fog Volume is a sphere and Unity’s Local Volumetric Fog a box, each placed in the world with a falloff or a blend distance at its edge. Godot’s FogVolume takes a shape or a fog shader. None lies over a region that a texture on the ground draws, with its top following the ground. The words are theirs: density and albedo as Godot’s FogMaterial and Unity’s volume take them, and color as the curtain’s.

A light mask can light the land it lights, such as the warm pool round each lantern at night. Give it a fillLight, and the texture’s green, blue and alpha are read as linear RGB light, 0 to 1 each. That light reaches every surface as the sky’s fill does, from every side, with the surface’s own colour and occlusion, so a character, a trunk and the ground in the pool all take it. fillLight holds color, white when left out, and intensity, 1 when left out, as an ambient light’s intensity: 1 lights a white surface under a texel of 1 as an ambient light of intensity 1 does.

Red and the light are apart, so a lantern low on fuel dims its pool and never moves its line. The light reaches wherever the texture holds it, the dark side too, so draw each pool inside its line. Pools join by adding, so draw them with an additive blend, where red joins by its larger value. Write an RGBAFormat texture: a fill light over a RedFormat one is an error in development. A canvas keeps its colours premultiplied by its alpha, so where alpha is low it loses them: write a DataTexture or draw into a render target.

A lamp whose light reaches past its pool lights the ground past the line too, and the line on the ground turns into a soft fade. Give the mask localLights, and the dark puts out every point and spot light under a height above the ground. Over that height, the lights reach as three draws them. A lamp then lights the trunks and the shades’ shoulders that stand past the line, on the side that faces it, while the ground and the low plants there stay dark. Inside the light, nothing changes.

It takes the following values:

  • height: the metres above the ground at the middle of the change. It defaults to the groundFog’s height, so the change lies inside the dark’s body, or to 1 m with no ground fog.
  • blendWidth: the metres over which the lights come back, centred on height, half the height when left out. 0 is a hard cut. It stays under twice the height, so the ground stays dark.

Then give the lamp a range past its pool, such as a point light’s distance at twice the pool’s radius. The rule reads where each surface stands, not the light’s path, as follows:

  • Every point and spot light in the scene takes it, a player’s flashlight and a thrown torch too.
  • A lamp inside the dark lights no ground near it, only what stands over the height.
  • The height is measured above the Landscape’s ground, or above y 0 with no Landscape, so a deck or a bridge past the line counts as standing over it.
  • A rect area light is not reached.

A lit material whose shader hook moves three’s point or spot light lines keeps its local lights in the dark, and a development build names it once. It costs a multiply for each point and spot light at each lit pixel, and one more read of the ground’s heights where the band’s height does not read them already. In Last Light’s forest edge at night, on an RTX 4070 SUPER at 1080p shared with other work, two alternating runs each with it on and off showed no difference the noise could resolve. The GPU’s median frame at Low was 13.0 and 9.5 ms on against 10.5 and 10.2 off, and at High 23.3 and 17.0 on against 16.7 and 22.7 off. A laptop at Low has not been measured.

Unity’s rendering layers, Unreal’s lighting channels, Godot’s cull mask and PlayCanvas’s light mask pick which objects a light lights, and three.js has none. None splits one ground at a region’s line. “Local lights” is Unreal’s word for point, spot and rect lights, which Unity’s URP calls additional lights.

A mask that changes each frame, such as lantern circles that move, grow or dim, is cheaper to draw on the GPU than to write on the CPU: a 512 by 512 texture is 262,144 texels a frame. Draw into a WebGLRenderTarget before the frame draws, as a useFrame at priority 0 does, and hand its texture to the mask. The mask reads a render target once three has made it on the renderer. A WebGLRenderTarget filters with LinearFilter both ways by default, as a boundary needs. After the browser loses the canvas’s context and gives it back, the mask reads nothing until you draw into the target again, so draw it every frame or after each restore.

The engine’s tests run these two files. The first is the one answer to “is this point in the light”, with no imports, so the room reads it without the renderer:

packages/engine/test/outside/lanternLight.ts
// The one answer to "is this point in the light", in a module of its own
// with no imports, so the room reads it without the renderer.
/** A lantern's place on the ground, the radius of the circle it claims, in
* metres, and its fuel, 0 to 1, which dims its light and never shrinks
* its circle. */
export interface Lantern {
x: number;
z: number;
radius: number;
fuel: number;
}
/** The lit land at one moment: the lantern circles, and, while the dark
* pours across the map from -x, the x of its front, past which the land
* it has not reached yet stays lit. */
export interface LanternField {
lanterns: readonly Lantern[];
front?: number;
}
/** How far a point lies inside the lit land, in metres, negative outside
* it. The one answer to "is this point in the light": the room's check
* reads it, and the mask is a picture of it. */
export function readLanternDistance(
{ lanterns, front }: LanternField,
x: number,
z: number,
) {
let distance = front === undefined ? -Infinity : x - front;
for (const lantern of lanterns)
distance = Math.max(
distance,
lantern.radius - Math.hypot(x - lantern.x, z - lantern.z),
);
return distance;
}
/** Whether a point stands in the light. */
export const isInLanternLight = (field: LanternField, x: number, z: number) =>
readLanternDistance(field, x, z) >= 0;
/** Seconds the dark takes to pour across the map at dusk. */
export const pourSeconds = 45;
/** The dark's front `seconds` into its pour, from x -100 to x 100, 4.4 m
* a second: before it, every place is lit, and after it, only the
* circles. */
export const readPourFront = (seconds: number) =>
-100 + 200 * Math.min(Math.max(seconds / pourSeconds, 0), 1);
/** Seconds a lantern takes to root. */
export const rootingSeconds = 5;
/** A rooting lantern's radius `seconds` into its rooting, from `from` to
* `to`: fastest at first, settling over the last second. */
export function readRootingRadius(from: number, to: number, seconds: number) {
const share = Math.min(Math.max(seconds / rootingSeconds, 0), 1);
return from + (to - from) * (1 - (1 - share) ** 3);
}

The first file also holds the pour, a dark that crosses the map in 45 s, and the rooting, a circle that steps outward in 5 s. Both are functions of a clock, so the room’s check and the picture read one answer at one moment.

The second draws each lantern as one instance of a square, written in place each frame: its rim’s distance into red with a max blend, then its light into green, blue and alpha with an additive one. The pour’s front is one more square over the whole mask, joined by the larger red. read gives the lit land at the scene’s clock, and the curtain on the line leans with the pour and the rooting with no code of its own:

packages/engine/test/outside/LanternBoundary.tsx
import { useFrame } from "@react-three/fiber";
import { useEffect, useMemo } from "react";
import {
AddEquation,
Color,
CustomBlending,
InstancedBufferAttribute,
InstancedBufferGeometry,
MaxEquation,
Mesh,
OneFactor,
OrthographicCamera,
PlaneGeometry,
Scene,
ShaderMaterial,
WebGLRenderTarget,
type Texture,
type WebGLRenderer,
} from "three";
import {
Landscape,
Views,
type LightMaskOptions,
type Look,
} from "@spawnite/engine";
import type { LanternField } from "./lanternLight";
/** Metres the mask spans along x and along z, centred on the map. */
export const maskSize = 200;
/** Texels along each side: 0.4 m a texel. */
export const maskTexels = 512;
/** Metres red spans from 0 to 1 across each circle's rim: ten texels, so
* the band reaches 2 m into the dark before red stops changing. */
export const rampWidth = 4;
/** The lanterns' warm light at full fuel, linear. */
const lanternLight = new Color(1, 0.55, 0.22);
// Each lantern is one instance of a square on the ground, drawn straight
// into the mask's clip space: +x along u and +z along v, as the mask
// reads them.
const discVertex = /* glsl */ `
attribute vec4 lantern;
uniform vec4 area;
uniform float reach;
varying vec2 offset;
varying vec4 shape;
void main() {
offset = position.xy * ( lantern.z + reach );
shape = lantern;
vec2 ground = lantern.xy + offset;
gl_Position = vec4( ( ground - area.xy ) * area.zw * 2.0, 0.0, 1.0 );
}
`;
// Red: the distance to the circle's rim as the boundary reads it,
// readLanternDistance's own sum. Joined by the larger, so two circles
// make their union.
const rimFragment = /* glsl */ `
uniform float rampWidth;
varying vec2 offset;
varying vec4 shape;
void main() {
float distance = shape.z - length( offset );
gl_FragColor = vec4( clamp( 0.5 + distance / rampWidth, 0.0, 1.0 ), 0.0, 0.0, 0.0 );
}
`;
// The dark's front as it pours: one square over the whole mask, its red
// the distance past the front, joined with the circles by the larger.
const frontVertex = /* glsl */ `
uniform vec4 area;
varying vec2 ground;
void main() {
ground = area.xy + position.xy * 0.5 / area.zw;
gl_Position = vec4( position.xy, 0.0, 1.0 );
}
`;
const frontFragment = /* glsl */ `
uniform float rampWidth;
uniform float front;
varying vec2 ground;
void main() {
gl_FragColor = vec4( clamp( 0.5 + ( ground.x - front ) / rampWidth, 0.0, 1.0 ), 0.0, 0.0, 0.0 );
}
`;
// Green, blue and alpha: the lantern's light, brightest at its foot and
// gone at its rim, times its fuel. Joined by adding, so two pools that
// overlap light it twice.
const lightFragment = /* glsl */ `
uniform vec3 color;
varying vec2 offset;
varying vec4 shape;
void main() {
float fall = 1.0 - smoothstep( 0.0, shape.z, length( offset ) );
gl_FragColor = vec4( 0.0, color * fall * fall * shape.w );
}
`;
/** Lanterns the draws hold at most. */
export const lanternLimit = 64;
/** The mask's draws: every circle's rim by max, then every pool's light by
* adding, one instanced square a lantern each, and the pouring dark's
* front by max. Written in place by `write`, so a lantern that moves,
* grows or dims builds nothing. */
export function createLanternDraws() {
const square = new PlaneGeometry(2, 2);
const geometry = new InstancedBufferGeometry();
geometry.index = square.index;
geometry.setAttribute("position", square.getAttribute("position"));
const instances = new InstancedBufferAttribute(
new Float32Array(lanternLimit * 4),
4,
);
geometry.setAttribute("lantern", instances);
geometry.instanceCount = 0;
const shared = {
area: { value: [0, 0, 1 / maskSize, 1 / maskSize] },
reach: { value: rampWidth / 2 },
};
const rims = new ShaderMaterial({
vertexShader: discVertex,
fragmentShader: rimFragment,
uniforms: { ...shared, rampWidth: { value: rampWidth } },
depthTest: false,
depthWrite: false,
blending: CustomBlending,
blendEquation: MaxEquation,
blendEquationAlpha: MaxEquation,
});
const light = new ShaderMaterial({
vertexShader: discVertex,
fragmentShader: lightFragment,
uniforms: { ...shared, color: { value: lanternLight } },
depthTest: false,
depthWrite: false,
blending: CustomBlending,
blendEquation: AddEquation,
blendEquationAlpha: AddEquation,
blendSrc: OneFactor,
blendDst: OneFactor,
blendSrcAlpha: OneFactor,
blendDstAlpha: OneFactor,
});
const fronts = new ShaderMaterial({
vertexShader: frontVertex,
fragmentShader: frontFragment,
uniforms: {
area: shared.area,
rampWidth: { value: rampWidth },
front: { value: 0 },
},
depthTest: false,
depthWrite: false,
blending: CustomBlending,
blendEquation: MaxEquation,
blendEquationAlpha: MaxEquation,
});
const scene = new Scene();
for (const [order, material] of [rims, light].entries()) {
const draw = new Mesh(geometry, material);
draw.frustumCulled = false;
draw.renderOrder = order;
scene.add(draw);
}
const front = new Mesh(square, fronts);
front.frustumCulled = false;
scene.add(front);
return {
scene,
write: ({ lanterns, front: frontX }: LanternField) => {
if (lanterns.length > lanternLimit)
throw new Error(
`${lanterns.length} lanterns are more than the mask's ${lanternLimit}: raise lanternLimit.`,
);
lanterns.forEach(({ x, z, radius, fuel }, index) =>
instances.setXYZW(index, x, z, radius, fuel),
);
instances.needsUpdate = true;
geometry.instanceCount = lanterns.length;
front.visible = frontX !== undefined;
fronts.uniforms.front.value = frontX ?? 0;
},
dispose: () => {
square.dispose();
geometry.dispose();
rims.dispose();
light.dispose();
fronts.dispose();
},
};
}
/** The mask's render target: red for the rims, green, blue and alpha for
* the light, filtered so the line falls between texels. */
export const createLanternTarget = () =>
new WebGLRenderTarget(maskTexels, maskTexels, { depthBuffer: false });
// The draws' camera, which their shader does not read.
const camera = new OrthographicCamera();
const cleared = new Color();
/** Clears `target` to dark and draws the lanterns into it. */
export function drawLanternMask(
renderer: WebGLRenderer,
target: WebGLRenderTarget,
scene: Scene,
) {
const previous = renderer.getRenderTarget();
const alpha = renderer.getClearAlpha();
renderer.getClearColor(cleared);
renderer.setRenderTarget(target);
renderer.setClearColor(0x000000, 0);
renderer.clear(true, false, false);
renderer.render(scene, camera);
renderer.setRenderTarget(previous);
renderer.setClearColor(cleared, alpha);
}
/** Draws the lit land into the mask's target each frame before the frame
* draws, as `read` gives it at the scene's clock, so a lantern that
* moves or dims and the pouring dark show on the next frame, and a
* context that was lost and restored draws it again at once. A view: a
* room mounts none, and the room needs no picture. */
export function LanternMaskDraw({
read,
target,
}: {
read: (seconds: number) => LanternField;
target: WebGLRenderTarget;
}) {
const draws = useMemo(() => createLanternDraws(), []);
useEffect(() => () => draws.dispose(), [draws]);
// Priority 0, before the frame draws.
useFrame(({ gl, clock }) => {
draws.write(read(clock.elapsedTime));
drawLanternMask(gl, target, draws.scene);
});
return null;
}
/** The mask over the lantern circles: the sun stops at each circle's rim,
* a band of thicker dark presses on it, a curtain of dark air stands on
* it, and each lantern's warm light lights its circle. */
export const createLanternLightMask = (texture: Texture): LightMaskOptions => ({
texture,
size: [maskSize, maskSize],
fill: 0.15,
fog: { tint: "#2a3550", density: 3 },
boundary: {
rampWidth,
blendWidth: 0.3,
band: { width: 1.5, darkness: 0.6, fogDensity: 2, height: 2 },
rim: { color: "#ffc68a", intensity: 0.6, width: 0.25 },
curtain: { height: 2.5, color: "#232833", opacity: 0.95 },
},
fillLight: { intensity: 2 },
});
/** The lit land, as `read` gives it at the scene's clock, on the dark
* side of the world; the room's check reads the same `read` at its
* own clock. */
export function LanternBoundaryScene({
read,
look,
}: {
read: (seconds: number) => LanternField;
look: Look;
}) {
// A render target is a plain object until a renderer draws into it, so
// the room makes one too and never draws it.
const target = useMemo(() => createLanternTarget(), []);
useEffect(() => () => target.dispose(), [target]);
return (
<>
<Landscape
map="meadow"
look={look}
lightMask={createLanternLightMask(target.texture)}
/>
<Views>
<LanternMaskDraw read={read} target={target} />
</Views>
</>
);
}

Off by default. On, it costs one texture read for each lit pixel, and four for each pixel of the height fog, which reads the mask along each eye’s ray, weighted by the fog’s density there.

In the forest edge at High, at 1080p on an RTX 4070 SUPER, the GPU’s frame took 4.26 ms without it and 4.38 ms with it, over three alternating runs each, with the machine 42 to 54% busy from other work. An earlier, shorter sweep had one run with the mask at 8.03 ms against 4.10 to 4.57 ms without, under heavier load; the three-run sweep did not repeat it. Turning it on compiles each lit material once more, under the loading screen when the Landscape mounts with it, and ahead of its first frame when a mask is added later.

A curtain is one instanced draw of strips, one instance for each spacing-wide cell out to far, and one 512 by 512 draw a frame that keeps the line’s motion. A cell the line does not cross draws nothing, so its cost is mostly the strips’ pixels.

It was measured in the light mask boundary story, low over the meadow toward the two circles, on an RTX 4070 SUPER with the machine 82 to 100% busy from other work. Each run is the GPU’s frame time, over three alternating runs each:

  • At Low, 1280 by 720: 0.79, 3.69 and 0.49 ms with it, and 0.47, 0.44 and 0.48 ms without. The middle run with it is an outlier, so at Low it adds up to about 0.3 ms.
  • At High, 2560 by 1440: 5.59, 3.89 and 4.09 ms with it, and 5.22, 3.49 and 3.34 ms without, about 0.5 ms more.

A laptop at Low has not been measured.

Keeping a sun or a litSun share adds one multiply to each lit pixel and no read. It was measured in the forest edge at night at High, at 1080p on an RTX 4070 SUPER, with the machine 10 to 87% busy from other work. Over three alternating pairs, the GPU’s median frame read 8.7, 10.5 and 12.2 ms with 0.7 kept, against 7.2, 9.1 and 14.2 ms with none: no difference the noise resolves.

A sunMap adds one texture read to each lit pixel, one to each texel of the light off the ground, and four to each pixel of the height fog where it glows toward the sun. Each lit material binds one more texture once a map has been set, and keeps it after the map is dropped. On the forest edge at night at High, its busiest lit material went from 12 to 13 of the 16 textures WebGL2 allows. It was measured on the forest edge at night with a 256 by 256 map, at 1080p on an RTX 4070 SUPER with no frame cap, over two alternating pairs at each level, with the machine 26 to 85% busy from other work:

  • At High, the GPU’s median frame read 5.44 and 6.51 ms with the map, against 6.23 and 5.41 ms without.
  • At Low, it read 4.86 and 4.83 ms with the map, against 6.95 and 4.41 ms without.

Neither level shows a difference the noise resolves.

A boundary adds a few instructions to each lit pixel and no draw. In the light mask boundary story at High, 2560 by 1440 on an RTX 4070 SUPER, the GPU’s frame took 3.06 ms with it and 2.86 ms with the same mask read as shares, over three alternating runs each, with the machine 53% busy from other work. At Low, over five alternating runs each, it took 2.09 ms with it and 1.46 ms without, but the runs spread from 0.4 to 2.6 ms, and two of the five pairs were equal, so the difference at Low is within the noise of that machine. Both frames include the mask’s own draw into its render target. A fill light reads the same texel as red, so it adds no texture read.

It reaches every MeshStandardMaterial, MeshPhysicalMaterial, MeshLambertMaterial, MeshPhongMaterial, MeshToonMaterial and an avatar’s MToon in the scene, with a game’s own shader hook kept. A lit ShaderMaterial of your own draws without it, and a development build names the material once in the console. An unlit material, such as a MeshBasicMaterial, stays as it is. At Low and Minimum, where no height fog draws, the plain fog still darkens. Under a WebGPURenderer the mask is off, as WebGPU lists. A value out of range is an error in development; a deployed game draws no mask and logs why.

Unity hangs a cookie on a directional light, Unreal a light function, and PlayCanvas a cookie on a spot or omni light; three.js maps a texture only through a spot light. Each scales that light’s direct light alone and reads the texture along the light. A light mask reads straight down onto the ground, so a circle’s rim stays where it was drawn whatever the sun’s angle. It also dims the fill and the fog, because a region lit by the sky alone still reads lit.

Under a closed canopy most of the light in the shade is sunlight the leaves above pass down and scatter. Global illumination gives it in Unity, Unreal and Godot; this renderer has none, so without help a grove’s crowns and floor take the look’s sky fill alone and read near-black at noon. canopy gives that light back. It is a texture laid over the ground from above, handed to Landscape or Lighting as canopy={{ texture, size: [x, z] }}. Its red channel says how closed the canopy is over each spot, 0 open sky to 1 a closed crown, and its green how high the canopy’s top stands there. Its type is CanopyOptions, from @spawnite/engine. Every lit surface under the top takes a share of the sun’s light from every side, as an ambient light gives, more the deeper it stands under the top: a crown’s lower tiers, the trunks, the floor and the characters. A crown’s sunlit top keeps its own shading, as it stands in the open sky.

The canopy takes these values:

  • texture: the cover and the top, a DataTexture of type HalfFloatType and format RGFormat, its data a Uint16Array of DataUtils.toHalfFloat values, two to a texel. Red is the cover, from 0 to 1, where 1 is a closed crown. Green is the top’s height in the world in metres times the cover, so a texel at a crown’s edge filters to its crown’s top rather than toward the ground. The top is the crowns’ upper surface over each spot, a cone’s slope from its apex to its widest, not the apex over its whole skirt. Its u runs along +x and its v along +z. The first texel is the -x, -z corner and its rows run along +z, so a texel at a column and a row starts at data[2 * (row * width + column)]. Keep its colour space NoColorSpace and give it a LinearFilter. Half float filters on every WebGL2 device; a 32-bit float texture needs an extension many phones lack, and 8 bits cannot hold metres. Past its edge no canopy stands. Write it as the game runs and set its needsUpdate.
  • size and center: the metres it spans, [x, z], and the point on the ground under its middle, [x, z], [0, 0] when left out.
  • intensity: the share of the sun’s light on open ground a closed canopy passes down, measured against the sun rather than as an absolute light. 0.1 when left out, a tenth of what the sun gives the open ground beside it.
  • color: the colour of that light, #e6f2c4 when left out, the pale green of light through leaves. Keep it pale: the surfaces it falls on keep their own colour, and a saturated green would turn a leaf green twice.
  • depth: the metres under the top over which the light grows from none to all of intensity, 6 when left out, about the upper third of an 18 to 24 m spruce, where its tiers stand open to the sun and the sky. A surface at the top takes none, one depth or more under it all.

The light follows the sun: its colour, its height over the horizon and the hour, so it dims through twilight and is gone at night. A light mask’s dark takes the mask’s sun share of it, none by default, and its lit land the mask’s litSun share, all by default. Inside a crown it reaches the leaves the crown’s own interior darkness leaves out, and it lights a leaf from behind too.

Draw the texture from the trees you place, on a grid of about 1 m. Draw each crown’s footprint whole to about 0.8 of its radius, fading to none at 1.5 times it. Where two crowns overlap, take the larger value or a sum held to 1. Options passed as a new object each render are fine, so an inline literal works.

The same depth hides the open sky’s reflection, which a closed crown does not let through: a glossy surface or a lawn’s sheen under a grove reflects none of the sky a depth under the top. The sky’s diffuse fill is not dimmed under it. A roof or a flying character above the top takes none of the light. A scene takes one canopy: draw every grove into its texture, since a second in one scene is an error. A size of 0 or less, an intensity below 0, a depth of 0 or less, a texture in SRGBColorSpace, or one that is not HalfFloatType with a green channel is an error in development; a deployed game draws no canopy light and logs why. Under a WebGPURenderer the light is off, as WebGPU lists.

These were measured on 2026-10-16, before the light knew the canopy’s top. In the forest edge’s groves at High, walked from the game’s camera, the crowns over the top three fifths of the frame read a median of 42, 47 and 54 out of 255 at 10, 20 and 30 m without it, and 57, 60 and 65 with the default intensity. The share of the frame under a tenth of full value fell from 21.6% to 10.0% at 10 m. With the depth, the same crowns take less of the light toward their tops. At the start of the forest’s grove walk, a spruce’s crowns read a median of 28 at 0.06 against 33 before the depth, and 34 at 0.12. A game can give its floor twice the light and keep its crowns where they were.

Off by default. On, it costs one texture read and a few multiplies for each lit pixel, about 0.1 ms of a GPU frame. On the forest edge at its spawn camera, at 1920 by 1080 on an RTX 4070 SUPER, the GPU frame’s median took 22.20 to 22.53 ms with the canopy and 22.13 to 22.47 ms without at High, over four alternating rounds with the machine 21 to 47% busy. At Low the scene’s pass took 4.14 and 4.19 ms with it and 4.03 to 4.11 ms without, over two rounds with the machine 18 to 43% busy. Those runs were on 2026-10-17. With the texture read replaced by a constant the pass cost the same, so the read itself costs nothing measurable here.

An earlier sweep that day read 24 to 30 ms with the canopy and 17.6 ms without, with the machine 39 to 90% busy, and the rounds above did not repeat it. Read a cost from rounds on a quiet machine, as measuring a frame says.

None of the five engines ships a canopy’s light: Unity’s light probes and Adaptive Probe Volumes, Unreal’s Lumen and Godot’s SDFGI, VoxelGI and LightmapGI compute it. The depth under the top stands in for what Unreal’s distance field ambient occlusion and Godot’s SDFGI read from the geometry: how much canopy stands over a point. Without them, Godot’s ReflectionProbe gives a box its own ambient, Roblox splits Ambient under cover from OutdoorAmbient, and Epic raises a Sky Light’s Min Occlusion so foliage interiors never go black. A texture lets any shape of forest drive the light, which a box cannot, and the light follows the sun, which a fixed ambient does not.

Each look lights characters with a soft warm light that only they receive, from beside the camera. Under a high sun a face catches little of the sun and takes the sky’s blue, so it reads darker and cooler than its texture; this light keeps it at its own colours. It reaches every character, the player’s, other players’ and NPCs, whichever view draws it, with what it holds and anything a game’s view draws inside it. The scene around the character takes none of it, and it casts no shadow.

The look’s characterLight holds the following values:

  • intensity: as a directional light’s, at the look’s hour. It dims and brightens with the sky as the clock moves on, as the environment’s light does. The noon look’s is 1.
  • color: the light’s colour, a warm white in the day looks and a cool blue in night.
  • yawRadians and pitchRadians: where the light stands, seen from the camera, to the right of the view and above it. 0 and 0 light straight along the view.

Change one value with an override, such as characterLight: { intensity: 0.5 }, and the rest keep the look’s. To light your characters yourself, or to leave them in the scene’s light alone, pass characterLight: false. An avatar’s MToon keeps the sky’s light then.

The light reaches a character drawn in a MeshStandardMaterial, MeshPhysicalMaterial, MeshLambertMaterial, MeshPhongMaterial, MeshToonMaterial or an avatar’s MToon. Metal takes none of it, as metal takes no diffuse light. A character in another lit material, such as a ShaderMaterial of your own, draws without it, and a development build names the material once in the console. Under a WebGPURenderer the light is off, as WebGPU lists.

A model file’s own materials are shared by every draw of the file, so a character wears a lit copy of each, and the same file placed as a prop stays in the scene’s light. A material your own code makes and hands both a character and a prop lights the prop too: give the prop a material of its own.

Unreal links a light to some meshes with lighting channels, Unity with rendering layers and Godot with a light’s cull mask; Roblox lights characters with the scene. Those engines leave the linking to the creator.

A look’s characterBlobShadow lays a soft dark disc on the ground under every character, at every quality level. At the Low quality level the sun casts no shadow, so a character with no disc seems to float. The disc ties the feet to the ground. As the character jumps, the disc stays on the ground and widens and fades, so a player reads how high the character is. At a level where the sun’s shadow draws, the disc darkens the ground under the feet beside it. Every built-in look leaves it off.

Unity’s blob shadow projector and Unreal’s capsule shadows answer the same need. “Contact shadow” names a different thing in Unreal and in Unity’s HDRP: a screen-space pass that sharpens a shadow where it meets a surface.

Give the look a characterBlobShadow through an override, such as look={{ base: noon, characterBlobShadow: {} }}, and the values you leave out come from defaultCharacterBlobShadow. A scene changes it as it changes any other look value, as overriding a value says. The look takes the following values:

Value What it does Default
color The colour the disc darkens toward at its middle. #2a1d10
opacity How much the disc’s middle darkens a bright ground with the feet on it, 0 to 1, as the player sees the frame. 0.55
radiusScale The disc’s radius with the feet on the ground, as a multiple of the character’s capsule radius. 1.3
fadeHeight Metres of the feet above the ground at which the disc has faded out. It widens by half on the way. 2.5

An opacity outside 0 to 1, a scale or a height of 0 or less, or a colour that is not one throws in development. A deployed game draws no disc and logs why.

Each frame, a ray goes down from each character’s drawn body. The disc lies where the ray meets a fixed or kinematic body, such as the ground, a prop or a moving platform, turned to that surface. The ray passes through other characters and through dynamic bodies, such as a ball, so the disc never jumps onto them. A character lays no disc in each of the following cases:

  • Its drawn body is hidden.
  • Nothing stands under it within its capsule radius plus fadeHeight.
  • The surface under it is steeper than the character controller’s maxSlopeRadians.

A disc that lies half over a ledge’s edge floats past the edge, as a blob shadow does in most games. Every disc draws in one draw call, whatever the number of characters. It darkens the frame by a share and never lightens it, so it reads on dark ground too.

The look’s grading is where the grade starts. To move it while the scene runs, such as warming the frame through a sunset and cooling it at midnight, write the live grade that useLookGrading returns, in a useFrame, as you would a material’s color. The look’s stack takes it into its passes before it draws each frame, so easing it rebuilds nothing and costs no more than the writes.

import { useFrame } from "@react-three/fiber";
import { Color } from "three";
import { useLookGrading } from "@spawnite/engine";
const warm = new Color("#fff0e2");
const cool = new Color("#e4ebff");
export function NightGrade({ night }: { night: { current: number } }) {
const grading = useLookGrading();
useFrame(() => {
// 0 at dusk, 1 at midnight.
grading.tint.lerpColors(warm, cool, night.current);
grading.saturation = -0.12 * night.current;
});
return null;
}

The live grade holds hue, saturation, brightness, contrast and tint, the same values as the look’s grading, with tint a three.js Color to write in place. It also holds the display grade’s operations at the values that leave the frame as it is. Under a grade before the tone mapping, a development build warns once when a game writes one, since nothing draws it. The look fills it when it mounts and again when the scene hands Landscape another look. A scene that mounts its own <PostProcessing>, or a player’s quality level whose grading is off, draws none of it, and a write to it is harmless.

The world’s weather adds its temperatureOffset and saturationOffset as the frame draws, after the game’s write, so the live grade keeps the game’s values and both draw. A scene whose weather is false draws neither offset.

Unity blends post-processing volumes by weight, and Unreal lerps a post-process volume’s settings, to grade by time of day. Roblox tweens a ColorCorrectionEffect’s TintColor and Saturation, and Godot sets an Environment’s adjustments from a script. The live grade takes Roblox’s and Godot’s shape, one grade whose values a script writes, because a game’s own clock, such as a night’s stops, already knows where it stands: no volumes to place, and the look stays one value.

toneMapping names the curve that maps the frame’s light to the screen, after the exposure, as Unity’s and Godot’s tonemapper modes do. Left out, it is ToneMappingMode.ACES_FILMIC. A look takes LINEAR, REINHARD, CINEON, ACES_FILMIC, AGX or NEUTRAL: the curves three.js’s renderer also draws, so a quality level with no post-processing stack maps the frame with the same curve as one with a stack.

ToneMappingMode.LINEAR maps no curve and keeps the exposure, as Godot’s Linear and three.js’s LinearToneMapping do. At exposure 1 an unlit colour draws as it is, and the night still darkens it. The pixel look maps with it.

sunShadows: false stops the sun by day and the moon by night casting their shadow: the cascades and the far shadow map both, whatever the Landscape’s or the quality level’s map sizes. Left out, the sun casts.

Picking a look opts the game in to post-processing: Landscape mounts the look’s stack, and the devtools show its passes’ sliders. A scene that mounts its own <PostProcessing> keeps it: the look mounts no stack beside it and logs a warning, so the frame is drawn once. Pass postProcessing: false to keep your own stack without the warning.

Roblox sets a scene’s light with fixed settings on its Lighting service, and Unity and Unreal leave the sky, fog and post-processing volume for the creator to tune. Godot gathers them in one Environment resource. A look is closest to Roblox’s: the creator picks a look and never tunes a stack, and an agent starts from a finished look and changes one value at a time.

A scene that draws its own ground, such as a track, has no map to hand Landscape. Mount Lighting instead. It sets the same sky, sun, look and stack as Landscape does. With no Landscape and no body, a game loads no physics, and with no Landscape it loads no navmesh unless its loading screen does, as Landscape says:

packages/engine/test/outside/TrackLight.tsx
import { Lighting } from "@spawnite/engine";
import { morning } from "@spawnite/engine/looks/morning";
export function TrackLight() {
return <Lighting look={morning} shadowDistance={120} />;
}

With no day clock in the world, the sun stands at the look’s hour. shadowDistance is how far along the view the sun’s shadow reaches, 60 m by default, since Lighting reads no quality level; a chase camera down a track reaches farther.

To keep a painted sky, pass sky: an equirectangular image, and sunU, the column its sun stands in from 0 to 1 across. The image is drawn in place of the rig’s sky, turned so its sun stands on the rig’s. intensity multiplies its brightness linearly, as three.js’s backgroundIntensity does, so a deep blue keeps its depth under a bright look’s exposure. The models take their soft light from the image as it is drawn, at its intensity, under the look’s environment.intensity; a look’s environment.image lights them in its place. Lighting takes the same sky, sun and fog as Landscape, and sky={false} draws no sky at all, as Landscape describes.

import { Lighting } from "@spawnite/engine";
import { dusk } from "@spawnite/engine/looks/dusk";
import dawn from "./sky-dawn.webp?url";
export function DawnLight() {
return <Lighting look={dusk} sky={{ file: dawn, sunU: 0.5 }} />;
}

An image’s width sets how sharp its far land reads. A 4,096-wide image holds about 11 texels a degree, and a 1,600-pixel screen that spans 56 degrees draws about 27 pixels a degree, so its painted trees blur. An 8,192-wide image holds about 23. Paint it from a source at least that fine: an upscale adds texels, not detail.

The engine sizes a painted sky’s cube map from the image, its width over pi capped to the device’s limit, which keeps every texel the image holds. three.js alone makes faces as large as the image is tall, about 2.5 times the memory. In the forest edge the 8,192 by 4,096 image took about 0.1 GB more of the GPU’s memory than a 4,096 by 2,048 one, with no change to the frame time. Under WebGPU, three.js still makes its own cube map.

The browser decodes an image drawn straight into the cube off the page’s thread, so a large sky does not stop the loading screen’s bar. The forest’s took 70 to 85 ms of the page’s time to upload, where decoding it on the page took 400 to 1,000 ms. An image with anchors or haze is redrawn on the page first, so it decodes there.

Until the image is in, the engine lights the scene from a bake of nothing at the size of the image’s bake, and the loading screen waits for the image’s bake. So each lit shader compiles once, for the light it keeps, as Shaders compile under the screen says.

A painted or generated panorama often paints its horizon off its middle row, or paints its mountains taller than an equirectangular image would show them. The sky object that Landscape and Lighting take, a LookBackground, has two more values for such an image: anchors and haze. anchors pins rows of the image to heights over the true horizon, so you set where its horizon sits and how tall its land stands without editing the file. Each anchor takes the following values:

  • row: the image’s row, 0 at its top and 1 at its bottom.
  • elevationRadians: the height over the true horizon the row is drawn at, negative under it.

The rows between two anchors, and out to the zenith and the nadir, spread evenly, so the sky above the top anchor stretches or squeezes to fill the rest of the way up. One anchor, such as { row: 0.55, elevationRadians: 0 }, puts the painted horizon on the true one. A second, such as { row: 0.36, elevationRadians: 0.12 }, stands the band between the two rows, the mountains, 7 degrees tall. Two anchors close together squeeze a band into a line, which shows as a seam.

haze lays a colour over the image at the horizon and everything under it, thinning to none higher up, as Roblox’s Atmosphere.Haze hazes a sky toward the horizon. Its values are the following:

  • color: the haze’s colour. It reaches the screen as the look’s fog colour does, through the same exposure and grade, and the sky’s intensity does not dim it, so the look’s fog colour meets the far ground without a seam at the look’s hour.
  • amount: how much of the image it hides at the horizon and under it, from 0 to 1.
  • heightRadians: the height over the horizon where it has thinned to none, easing out smoothly, such as 0.15. Set it below the top anchor’s elevationRadians to keep the mountains’ tops clear.

The engine redraws the image once with its anchors and haze when it loads, into a canvas the image’s size, and draws that in its place. The scene takes its soft light from the redrawn image, so its horizon, its mountains and its haze light the models where the player sees them. The haze stays fixed as the day clock moves, where the scene’s fog follows the hour. The columns keep their place, so sunU holds, but a painted sun inside a moved band moves with it. A browser limits a canvas’s size, lower on iOS than on a desktop; a sky of 2,048 by 1,024 stays well inside every limit. A row outside the image, two anchors that cross, or a haze out of range is an error in development; a deployed game draws the image as it is and logs why.

A sky typed as LookBackground, imported from @spawnite/engine, has its values checked as you write them. Last Light’s forest edge, games/last-light/src/scenes/ForestEdge.tsx, draws an 8,192 by 4,096 panorama with no anchors, its window painted at the elevations its camera sees. Unity’s panoramic skybox and Godot’s PanoramaSkyMaterial take an image drawn level, and PlayCanvas moves a dome’s centre to place its horizon.

Client, except the hour. Headless, Landscape mounts no rig and no stack, but the look’s hour still seeds the day clock, so a simulation opens on the same hour a player sees.