Log inGet started
World

Spooky Spook Spook

Branchmain
Branchesmain
Commitcbb5416a1f

README.md

CryptSky

The Spooky Spook Spook night sky. It is attached to the scene entity "Sky" in scenes/main.scene and builds everything it needs as children of that entity. Each child is marked setTemporary(true), so none of them is saved into the scene.

ChildBuiltWhat it is
crypt_sky_domeawake (edit and play)A Skybox over game.sky.crypt_sky_mat, the animated sky-domain shader game.sky.crypt_sky (see its README): a violet-black gradient, an ecto-green and candle-amber horizon glow, twinkling stars, a cratered moon with a halo and a green ring toward R.MOON_DIR, aurora wisps, mist bands and lightning.
volumetric_skyfirst update (play only)The engine's VolumetricSky: real raymarched v4 clouds, configured through Sky.configure as a ragged moonlit storm. The engine's depth-aware cloud layer composites them over the sky and behind arena geometry.
lightning_flashfirst updateA wide, far point light (radius 260 m, no shadows). It sits at 0 intensity except during a strike.

The cloud layer only exists in play, because VolumetricSky.update only runs there. Edit mode shows the shader sky alone.

Cloud setup

  • Moon as the sun: sunDir is R.MOON_DIR normalised. sunColor is a cold pale blue. sunIntensity is moonLightIntensity (1.6).
  • Colours: dark violet zenith and horizon, plus a faint ecto-green groundColor that gives the cloud bellies a sickly underglow.
  • Coverage: coverage is 0.40, with detail erosion 0.38, so the cover is ragged with gaps the moon peeks through.
  • Wind: windSpeed is {0.07, 0, 0.04}, a visible drift.
  • Altitude: the layer spans cloudBase..cloudTop, 240 to 640 m. That is far above the arena (radius 36, hills of about 30 to 60 m).
  • Quality: conservative on purpose. cloudSize 128, cloudHeight 64, maxSteps 96, shadowSteps 4, stepSize 9, noiseRegenRate 5.

Lightning

Every lightningMinGap..lightningMaxGap seconds a strike fires two to four flickers. Each flicker raises three things together:

  • the shader's lightning, flash_dir and flash_seed properties (a sheet glow plus a jagged bolt low on the skyline),
  • the cloud preset's sunIntensity (+9 x level),
  • the lightning_flash light, moved toward the strike.

0.6 to 1.8 s later it calls R.call("playSound", "thunder", nil, { volume = thunderVolume }). The clip is game/sky/thunder.soundClip. If GameAudio does not know a thunder clip, the call does nothing.

Public fields

  • clouds: boolean (true): whether play mode raises the volumetric cloud layer.
  • lightningEnabled: boolean (true): whether random strikes happen.
  • lightningMinGap: number (9) and lightningMaxGap: number (24): the seconds between strikes.
  • thunderVolume: number (0.55): thunder volume, 0..1.
  • moonLightIntensity: number (1.6): the moon's intensity as the cloud layer's sun.
  • coverage: number (0.40): the cloud coverage threshold. Higher values leave bigger gaps.
  • cloudBase: number (240) and cloudTop: number (640): the altitude of the cloud layer in metres.

Fields are read when the clouds are built, at the start of play.

Methods

  • :strike() fires a lightning strike now.

Lifecycle

  • awake() points the material's moon_dir at R.MOON_DIR and spawns the sky dome.
  • start() rebuilds the dome if it is missing.
  • update(dt) spawns the clouds and the flash light on the first tick, then schedules and animates lightning.
  • onDestroy() despawns its children and resets the shader's lightning to 0.

Usage

local sky = entity.find("Sky").component.get("CryptSky")
sky:strike()