Skip to content

Sky Demo

App: apps/sky_demo/

Demonstrates the four atmosphere capabilities from Block RFX A#6 (engine PLM-241 / ADR 0076) in one scene: a full-screen sky (Graphics.setSky) — first a procedural gradient, then an environment cubemap; an ambient fill (Graphics.setAmbient) that raises shadowed faces off black; and atmospheric distance fog (Graphics.setFog) that dissolves the receding cubes into the sky colour. A diagonal row of lit cubes recedes into the distance so the fog reads clearly across a single frame.

Terminal window
% ./plume3d sky_demo

A near-horizontal orbit camera keeps the sky in the upper screen. The demo captures two screenshots — the gradient sky (frame 60), then the cubemap sky (frame 90 switches to mode 1; frame 150 shoots) — proving both sky modes and that the shared ambient + fog carry across.

  • Loads a scene shader and the full-screen sky shader (built into a sky pipeline on first use):

    _shader = Graphics.loadShader("shaders/scene")
    Graphics.loadShader("shaders/sky") // the sky shader — plume3d_sky.slang, not the mesh ABI
  • Sets a raw-linear ambient fill (well above the old 0.03 constant, so shadowed faces read as clearly tinted) and a linear distance fog whose colour is matched to the sky base:

    Graphics.setAmbient(0.34, 0.37, 0.44) // raw linear
    Graphics.setFog(0.62, 0.70, 0.85, 0.0, 8.0, 30.0) // linear: clear to 8, fully fogged by 30
  • Loads a 6-face environment cubemap (order +X, -X, +Y, -Y, +Z, -Z) and points the engine at it:

    _cubemap = Texture.loadCubemap([
    "textures/cube/px.png", "textures/cube/nx.png",
    "textures/cube/py.png", "textures/cube/ny.png",
    "textures/cube/pz.png", "textures/cube/nz.png"])
    Graphics.setEnvironmentMap(_cubemap)
  • Starts with the procedural gradient sky (mode 0 — params[0..2] horizon, params[4..6] zenith), then switches to the cubemap sky (mode 1) mid-run:

    Graphics.setSky("shaders/sky", 0, [0.62, 0.70, 0.85, 0.0, 0.18, 0.32, 0.68, 0.0]) // in init()
    // in update(), frame 90:
    Graphics.setSky("shaders/sky", 1, []) // cubemap sky — the env cube is already set
  • Draws a diagonal row of six coloured cubes receding away: near cubes stay crisp and saturated, far ones fade toward the fog colour — the distance-fog gradient in one screenshot.

  • The sky needs a real perspective camera (it reconstructs a view ray per pixel); the demo uses a low-height Cam.orbit so the horizon sits mid-screen.
  • The sky pass rides the single-viewport post/plain path. The env cube feeds the sky here; sampling it from lit shaders for reflections (IBL) is a follow-up (ADR 0076 §5).

See Graphics → Sky, fog & ambient (A#6), Texture.loadCubemap, and the sky, fog & ambient guide. Screenshot-verified (gradient sky, then cubemap sky).