# God Rays Through a Door — `god-rays@1.0.0`

Shafts of golden light pouring through a doorway into a dark, dusty hall, motes floating in the beam. Loops perfectly.

A dark stone hall with light pouring in through an opening at the far end into dust-filled air. The shafts are real volumetric light: the doorway's shape, the pillars' shadows and the door leaf standing in the hall all cut the beam exactly, the foliage outside dapples it and drifts, and the air glows brightest when you look straight into the light. Dust motes float in the beam and flash as they turn, the bright opening blooms, and the camera creeps slowly forward. Choose the opening (a door ajar, a four-pane window or three pointed cathedral arches), the colour of the light (golden hour, dawn rose, moonlight or white), how dusty the air is, and whether there are pillars and motes.

- Kind: background; status: published; digest sha256:5e29f486efd6b18d9db4053f0240cd0e836703ad8cdb7bf1c70591986f154546
- Role: Background (WebGL shader, full frame): cinematic volumetric light for dramatic, spiritual and moody scenes.
- Implementation: three; entry `src/god-rays.js`
- Files: https://aipixelwizard.com/registry/god-rays/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/god-rays.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/god-rays/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/god-rays/1.0.0/index.html (open over http; it imports sibling packages by relative path)
- Dependencies (exact): `three@0.185.1` (source) — Renderer, the full-screen volume shader and the mote points.; `apw-runtime@1.0.0` (demo) — Demo harness.

## Exports
- `createGodRays(renderer, { width, height, scene?, color?, haze?, columns?, motes?, intensity?, exposure?, glow?, seed? }) => { render(time, loopSeconds, output?), dispose() }` — The whole scene (hall, light, haze, motes and bloom) drawn to the canvas or a render target.
- `SCENES: { door, window, cathedral }` — The three openings, with their stone colour.
- `LIGHTS: { gold, dawn, moon, white }` — Suggested light colours.

## Parameters
- `scene` (select one of door | window | cathedral, default "door") — Opening
- `light` (select one of gold | dawn | moon | white, default "gold") — Light
- `haze` (number 0.3–2, default 1) — Dust in the air
- `columns` (boolean, default true) — Pillars
- `motes` (boolean, default true) — Dust motes
- `exposure` (number 0.5–1.8, default 1) — Exposure
- `seed` (integer 1–999, default 3) — Seed: Changes the foliage's shadows and where the dust floats.

## Composition
- Inputs: Time within the loop; the opening, light colour, haze, pillars and motes.
- Outputs: A full frame, drawn by a volume shader, a layer of motes and a bloom.
- Coordinates: Metres: the hall is 8 wide, 7 high and 21 long; the opening is in the far wall, 12 m from the middle of the hall.
- Lighting: Self-contained: exact visibility of the sun through the opening, pillars and door leaf; forward-scattering haze; a little room fill.
- Timing: render(time, loopSeconds) is a pure function of time; frames render in any order.
- Works with: kinetic-title, stop-motion-feel, dither-animation
- Looking straight into the light the haze glows most: that is the forward scattering of real dust.
- The door leaf appears in the Door ajar opening only.

## Output and loop
- 1080×1080, 30 fps, 12 s, procedural
- Seamless loop: yes — The foliage's shadows drift round a circle, the motes orbit small loops a whole number of times, the camera, the door leaf and the cloud over the sun move as sines of the loop, so the last frame meets the first.
- Verified 2026-10-06 in Chrome 154.0.8037.97 headless on Linux 7.0.0-38-generic (x64), Node 22.14.0 (WebGL 2 via SwiftShader (software)); deterministic: yes; loop check: Frame 0 vs end state (progress 1): mean |Δ| 0.0000, max |Δ| 0 of 255.

## Use it
New project: Create a WebGLRenderer, createGodRays(renderer, { width, height }) and call render(time, loopSeconds) each frame.

Existing project: Copy src/god-rays.js and call render(time, loop, renderTarget) to use it as a backdrop texture.

Reuse ideas:
- Epic title: Cathedral arches with a serif title in the dark foreground.
- Spiritual narration: Door ajar at golden hour, motes on, behind a slow voice-over.
- Mystery: Moonlit hall under Dither Animation for a grainy, haunted feel.

## Limitations
- The hall is fixed: the opening, pillars and camera path are not parameters beyond those listed.
- The sun's direction drifts only a little; it does not move across the sky.

## License
MIT. Copyright (c) 2026 AI Pixel Wizard. Released under the MIT License. See LICENSE in this folder.
- three.js 0.185.1: MIT (https://github.com/mrdoob/three.js)

Provenance: Adapted from the owner's threejs-sketches/light-atmosphere/god-rays (MIT), rebuilt for AI Pixel Wizard in October 2026 as true volumetric light: analytic visibility through three openings, pillar and door shadows with growing penumbra, forward-scattering haze, dappled foliage, dust motes, bloom, and the frame/time contract.

