# Rose Window — `rose-window@1.0.0`

A great Gothic rose window of stained glass in dark stone, the sun passing behind it and dust turning in the light. Loops perfectly.

A cathedral's rose window seen head-on: a star at the heart, a ring of lens-shaped petals, a ring of twice as many, a ring of round windows, all held by ribs of dark stone, every pane cut into shards of jewel-coloured glass and leaded. The sun goes once round behind the window, blazing the glass white-hot where it stands, catching the stone and sending shafts of light across the dark wall, with motes of dust turning in them. Choose how many petals the window has, the glass (cathedral, jewel, sunset or indigo), the fierceness of the sun, the shafts of light, the dust, the thickness of the stone, the lead and the brightness.

- Kind: background; status: published; digest sha256:ba977bb06629dd5b2a0125c045823a58410b9ef8a3440fe3d5a7ca48fc24aa56
- Role: Background (WebGL shader, full frame): a reverent, glowing backdrop for titles, music, history and spiritual content.
- Implementation: three; entry `src/rose-window.js`
- Files: https://aipixelwizard.com/registry/rose-window/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/rose-window.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/rose-window/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/rose-window/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 shader and the bloom targets.; `apw-runtime@1.0.0` (demo) — Demo harness.

## Exports
- `createRoseWindow({ petals?, glass?, sun?, rays?, dust?, tracery?, lead?, brightness?, seed? }) => { scene, camera, material, setSize(width, height), update(time, loopSeconds), dispose() }` — The whole window as one full-screen shader: render its scene with its camera after setSize and update, ideally through createBloomPass.
- `createBloomPass(renderer, { width, height, glow?, exposure?, grain? }) => { render(scene, camera, output?), dispose() }` — A small bloom with filmic tone mapping: draws a scene to the canvas with its glow.
- `GLASS: { cathedral, jewel, sunset, indigo }` — Eight glass colours (sRGB hex) for each way of colouring the window.

## Parameters
- `petals` (integer 6–16, default 12) — Petals: Petals in the inner ring, an even number: the next ring has twice as many and the outer ring four times as many round windows.
- `glass` (select one of cathedral | jewel | sunset | indigo, default "cathedral") — Glass
- `sun` (number 0–1.5, default 1) — Sun: How fiercely the sun behind the window blazes through the glass.
- `rays` (number 0–1.6, default 1) — Shafts of light
- `dust` (number 0–1.6, default 1) — Dust
- `tracery` (number 0.6–1.4, default 1) — Stone: How thick the ribs of stone tracery are.
- `lead` (number 0–1.5, default 1) — Lead: How visible the lead lines between the shards of glass are.
- `brightness` (number 0.6–1.5, default 1) — Brightness
- `seed` (integer 1–999, default 4) — Seed

## Composition
- Inputs: Time within the loop; the number of petals, the glass, the sun, shafts of light, dust, stone, lead, brightness and seed.
- Outputs: A full frame, drawn by one shader on a full-screen quad.
- Coordinates: The window is a circle centred on the frame, 90% of its half-height in radius; its rings are the star (0 – 0.15), the petals (0.15 – 0.47), the double ring (0.47 – 0.735) and the roundels (0.735 – 0.985) of that radius.
- Lighting: Self-lit: the glass glows from the sun behind it, the stone and wall catch a little of the glow; the bloom adds the halo.
- Timing: update(time, loopSeconds) sets the loop phase; frames render in any order.
- Works with: kinetic-title, number-reveal
- The stone is a signed-distance field: rings, radial ribs, lens outlines (two overlapping circles) and roundels, repeated by folding the plane into its sectors.
- The glass is coloured by pane (ring, sector, inside the lens or not) and cut by a Voronoi pattern whose borders are the lead.

## Output and loop
- 1080×1080, 30 fps, 12 s, procedural
- Seamless loop: yes — The sun goes exactly once round its circle per loop, the shimmer of the glass and the shafts of light move on circles of a noise, and each mote of dust drifts in sines of whole cycles, 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, createRoseWindow() and createBloomPass(renderer, { width, height }); call rose.setSize(width, height), then each frame rose.update(time, loopSeconds) and bloom.render(rose.scene, rose.camera).

Existing project: Copy src/rose-window.js; render rose.scene with rose.camera into a render target (or through the bloom pass) as the backdrop of your scene.

Reuse ideas:
- Reverent backdrop for a choir or organ piece: Cathedral, twelve petals.
- Fantasy title scene: Jewel glass.
- Evening documentary title: Sunset glass.

## Limitations
- The window is always seen head-on and centred: no perspective or tilt.
- The pattern is a fixed design of a star and three rings; only the number of petals changes.

## 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/architecture-structure/webgpu-gothic-rose-window and light-atmosphere/stained-glass-sun (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original shader: ring and sector tracery as a signed-distance field, Voronoi shards with lead, the sun exactly once round behind the glass, shafts of light and dust on exact loops, and the frame/time contract.

