Skip to main content

Lighting & Day/Night Cycle

The lighting system progressively shifts from day to night as players advance through trail markers.

Architecture

  • LightingService (server) — Watches chunk progression, sets dayNight atom
  • LightingController (client) — Smooth visual transitions between Day/Night states

Progressive Tiers

Configured in shared/data/configs/lighting.ts:

Marker RangeDay ChunksNight ChunksDaylight %Feel
1–203260%Learning phase
21–402340%Dusk — sun setting
41–601420%Twilight — mostly dark
61–801910%Deep night
81–100010%Total darkness

Within each tier, the pattern repeats. For tier 1: Day, Day, Day, Night, Night, Day, Day, Day...

Prewarm Offset

The server generates 3 chunks ahead at startup. To prevent the cycle from advancing before the player moves, LightingService captures the initial chunk count and offsets progression:

const progression = chunkCount - this.initialChunkCount + 1;

This ensures the game starts on Day regardless of prewarmed chunks.

Client Transitions

Transition duration: 8 seconds with easing.

Lerped properties:

PropertyDayNight
ClockTime7.10
Atmosphere.ColorWhiteBlue-grey
EnvironmentDiffuseScale1.00.0
OutdoorAmbientDark bluePurple

Fog density increases progressively via fogOverrideAlpha atom.