# Original Metal rendering PulseCanvas uses MetalKit for its preview and a synchronous offscreen Metal path for export. Both share frame encoding and absolute soundtrack timestamps. Every design supports uniform content blur and optional white flashes. `VisualizerRenderer` draws through MetalKit. `SpatialVisuals.metal` supplies the spatial scenes. `OriginalGeometry.swift` supplies the mesh/point scenes; `Canvas.metal` draws their triangles and analytic lit ball sprites. The native fragment collection is compiled from `NativeCommon.metal` plus ten effect-family source files. The renderer loads no recovered shader binary, LLVM module, external preset, image texture pack or OpenGL engine. Every visual is PulseCanvas Metal source compiled at runtime; the app ships no prebuilt or extracted shader modules. `NativeCommon.metal` plus eleven `Native*.metal` files hold the native designs (see Native Metal designs). `SpatialVisuals.metal` draws the released spatial designs. `Canvas.metal` shades the OriginalGeometry triangle surfaces with supplied smooth vertex normals or deterministic per-triangle normals and draws the bead sprites of Double Twist and Arc Spray, computing each lit sphere analytically inside the sprite. Content blur and forward travel use `Strobe.metal`, which also contains the separate fullscreen white-flash pass. ### Retired designs A final duplicate review also withdrew development IDs 262 (Neon Needle) and 277 (Velvet Wormhole), near-copies within the radial web tunnel family; saved references resolve to Violet Velocity at 270. (That review also withdrew 245 and 259, which the owner later kept.) The owner's October 2026 review then kept 181 designs and withdrew 104 more (`docs/metal-keeper-selection.json`); withdrawn IDs open 101 LED Corridor. Seventy new designs were then appended at IDs 300–369 (`NativeExpansionBore/Portal/Kinetic/Flight/Material/Cosmos/Fractal/FractalTunnel.metal`, compiled after `NativeExpansionCommon.metal`). After the owner reviewed them, 324 was withdrawn and second versions of 20 designs were added at 370–389 (`NativeExpansionPortalII/FlightII/MaterialII/CosmosII.metal`). The current catalog offers 270 styles. Earlier 287-style checks include the now-withdrawn design. Thirteen released IDs are retired: 0–3, 5–9, 11 and 13 reproduced another application's point formulas, mesh kernels and compiled shaders; 14 drew authored points with those shaders; 30 duplicated Octagon Vault with square cells. Their code, shader modules and verification material have been removed. Each ID stays reserved in `NativeEffects.swift` with a replacement design, so projects, timelines, saved styles and favorites that name it open the replacement. Retired IDs are never offered in the library, the preset row, Studio's automatic order or random choices. | Retired | Opens | | --- | --- | | 0 Prism Wake | 20 Signal Tiles | | 1 Lumen Veil, 13 Vapor Run | 10 Aurora Fold | | 2 Pulse Well, 8 Recursive Corridor, 30 Grid Vortex | 22 Octagon Vault | | 3 Velvet Passage, 6 Glass Current | 29 Tidal Glass | | 5 Facet Flow | 23 Mercury Fold | | 7 Contour Flux | 17 Silk Current | | 9 Spiral Tide | 25 Ink Cyclone | | 11 Petal Passage | 15 Lotus Resonance | | 14 Scatter Flight | 41 Photon Rapids | ## Rendering calculations The shared content blur uses two separable nine-tap Gaussian passes with weights [1, 8, 28, 56, 70, 56, 28, 8, 1] / 256. Sample offsets are independent of distance from the canvas centre, so the whole image softens evenly rather than smearing radially near its edges. Clamp-to-edge sampling prevents opposite canvas borders bleeding into each other. Radius scales with the shorter canvas edge for consistent preview and export softness. The blur runs after forward zoom and before white flashes. Zero bypasses both passes. Existing project motionBlur values control this replacement effect. Bead sprite size is `clamp(pointSize * viewportScale / max(clip.w, 0.1), 1, 160)`, a world-space diameter projected at the bead's depth. Each sprite discards outside its disc and shades a sphere normal with diffuse, rim and specular terms from the vertex's palette color. ## Host bindings Canvas vertices carry position at byte 0, color at byte 16, and UV at byte 32, with a 48-byte stride. | Uniform | Bytes | Important field offsets | | --- | ---: | --- | | Canvas surface | 64 + 4 | MVP 0 (buffer 1), scene (buffer 2) | | Bead sprite | 80 | MVP 0, size 64, viewport scale 68 | | Content blur | 8 | Direction 0 | | Spatial / native frame | 176 | See `SpatialUniforms` | ## Geometry and coverage `OriginalGeometry.swift` implements the seven authored PulseCanvas canvas designs (IDs 15–21). Palettes and music deformation are applied on the host: vertex positions bend with spatial waves whose strength follows the attack swell, the low envelope and percussion momentum, all scaled by Chaos. Arc Spray and Double Twist sort their beads by depth and blend them over each other, retaining visible ball shapes and color, under a moving perspective camera with aspect-aware overscan. The other authored designs repeat as layered fields too; triangle surfaces use a depth buffer and derivative-based lighting. Resonant Shell uses 40 × 96 subdivisions to reduce geometry work, and CPU triangle sorting has been removed. ## Spatial designs `SpatialVisuals.metal` replaces the former clustered particles at IDs 4, 10, and 12 and adds IDs 22–29. IDs 4/12 use repeated three-dimensional sphere fields with moving wave offsets; 10 integrates translucent folded curtains. The five additional modes use a connected hexagonal honeycomb wire mesh warped into a vortex, a deformed gyroid surface, bent emissive filaments, a curved ink tunnel with camera travel and swirling volumetric walls, and individually rotating octahedra. IDs 27–29 add mirrored seeded block skylines, staggered groups of independently tumbling tori, and a continuous wave chamber. Surface modes use up to 64 conservative distance steps (128 for IDs 27–29; 160 with a tighter surface tolerance for Mercury Fold) with finite-difference normals; volume modes integrate 36 samples. Mercury Fold adds layered surface ripples, darker cavities, and sharper reflected highlights. A separate Liquid detail control (0–1) changes the ripple frequency and amplitude; it is saved in shared visualizer presets, randomized with appearance, and defaults to 0.6 for older projects. Ink Cyclone advances the camera along a curved world-space centreline. Cloud density follows a rippled cylindrical wall rather than a screen-space radial pattern, giving nearby layers forward expansion and distant layers parallax; source percussion accelerates the shared motion clock. The gyroid camera stays in an open cavity to avoid collapsing the view into a flat surface at the camera origin. ID 22 uses a continuous analytic tunnel coordinate field instead of surface marching. Octagon Vault uses six-sided honeycomb cells from a staggered lattice, sharing all edges with no square gaps. A logarithmic depth and angular warp bends all shared edges together, retaining an even repeat at the angular seam. Unwrapped pixel derivatives keep thin lines antialiased across the angular seam; a separate glow decays into a black background. Line width changes the stroke and glow rather than the cell shape. Music drives brightness, twist, movement, and camera pulses. The full-canvas pass runs on the GPU rather than generating tens of thousands of clustered points on the CPU. Halo Engine repeats staggered spatial groups across the canvas, with 1–12 rings per group, with seeded sizes, independent tumbling axes, drifting orbital radius, and staggered group rotation. Halo count defaults to six for earlier projects, saves with shared presets, is included in randomization, and snapshots into exports. Only three neighbouring angular sectors are evaluated per field sample so adding rings does not multiply the distance-field loop cost. Ring thickness remains independent of count. A 144-byte uniform block carries resolution, deterministic music time, scene ID, pulse/momentum/bass/treble, appearance controls including Chaos, liquid detail / halo count and zoom speed, and five explicit palette stops. Surface shading, depth attenuation, and volume color remain within those stops. The shared content-blur and white-flash passes run afterward. Studio sequencing, preset persistence, randomization, and export use the same renderer, retaining the older stable numeric scene IDs. `test-spatial-visuals.sh` captures actual GPU frames, checks pairwise differences with identical settings/palette, rejects a flat liquid-surface output, and measures completed 960 × 540 frames. The current eleven-mode sample takes roughly 0.5–6 ms/frame on this development Mac; this is a sampled measurement, not a promise for every resolution or Mac. ## Native Metal designs IDs 31–99, 100–199 and 200–299 are registered in `NativeEffects.swift`. Each entry names the design, its SF Symbol, its fragment function and file, the labels for the size and detail controls, and its default look. The array order is the permanent `native:` identity, so entries are only appended. IDs 0–30 are listed in the same registry with their original families or, for retired designs, their replacement, so names, icons, size labels and default looks come from one place; `RenderState.nativeSceneNames` and the catalog script read it. `NativeCommon.metal` is a shared prelude: the uniform block, a normalized `Ctx` (short-edge `uv` in [-1, 1], pixel size, procedural time, music clock, smoothed bands, attack swell, zoom travel and controls), hashing and noise, Voronoi and hexagonal cells, SDF helpers, palette lookup, a forward-moving layer stack with stable layer IDs, octave and log-polar zoom helpers, an oblique ground camera and the shared tone mapping with static dither. The renderer compiles `NativeCommon.metal` followed by each `Native*.metal` file (Flow, Structure, Geometry, Particles, Nature, Tunnels, Wormholes, Drive, Roads, Dance, Rave) when it attaches. A file that fails to compile disables only its own designs, which report the compiler message when selected. With a cold Metal cache this took about 0.45 s on an M3 Max; with a warm cache it takes about 20 ms. Each design is its own fragment function, generated by the `NATIVE_EFFECT` macro. Pipelines are created on first use and prewarmed in the background for the live view, so switching designs does not stall. Integrated families use `NativeExpansionCommon.metal` so their original integer noise, music-integrated motion and local rhythmic surface deformation remain intact. The worktree’s eleven families keep their own explicit music-clock consumption; applying the integration clock to them a second time would accelerate them twice. IDs are documented in `docs/native-import-mapping.json`. The native pass extends the spatial uniform block with smoothed band envelopes and a motion vector: zoom travel, music clock, procedural time and smoothed momentum. Procedural time is `source time × Motion speed` and never includes audio. Zoom travel integrates Zoom speed. The music clock integrates the source beat motion, scaled by Chaos and Motion speed. During live preview, changing Motion speed, Zoom speed or Chaos moves an offset instead of the value, so motion stays continuous while a slider is dragged. Offsets reset on seeks and scene changes, and offline frames never use them, so a frame at a given song time is identical in preview after a seek, in Studio playback and in export. Most native designs handle Zoom speed themselves and skip the forward-zoom post pass. Integrated dance families deliberately use the continuous compositor zoom, including a stationary framing at Zoom speed zero. Depending on the design, they fly through repeating 3D space with a clear camera channel, move a layer stack toward the viewer, translate hyperbolic or log-polar space, advance wave phases, or dolly a camera through a scene. ## Music and flashes Preview and export use `SoundtrackAnalyzer` at the exact source playhead. A centered 2048-sample Hann FFT averages channel power before producing 32 frequency bands. Amplitudes use a power curve that preserves dynamics, rather than compressing most audible content into the top of a decibel meter. Source-file analysis is independent of monitor volume and includes every channel. A continuous PCM pass builds a cached rhythm timeline on a 10 ms source grid. Channel-wise continuous low-pass filters split bass, body and treble energy; short RMS envelopes and adaptive rise gates locate attacks. This avoids filter startup transients from independent frame windows. Attacks produce a 65 ms exponential pulse, while a 700 ms leaky accumulator builds momentum from attack density. Steady energy does not schedule pulses. Source timestamps make seeking and different export frame rates consistent. Preview subtracts the player's downstream output presentation latency from the source clock. The per-visualizer Chaos value scales every visual pulse and frequency-band input. Source attacks drive local coordinate waves and swelling instead of a global breathing transform or camera jolt. Mesh vortices warp a shared lattice with integer angular harmonics to keep cell edges joined and the circumference seam continuous. Mercury Fold adds cavity-masked waves at two frequencies and position-dependent surface swelling; other spatial fields and volumes receive local flow. Vertex-based scenes bend points and surface patches with spatial waves in world coordinates. Deformation strength grows nonlinearly with Chaos, source pulse and percussion momentum. The existing source-integrated clock still accelerates procedural travel as percussion builds. At zero Chaos, source audio has no visual effect, including optional flashes, while procedural motion and configured zoom continue. Quiet passages release the extra deformation. Raw analysis remains intact; preview and export use the same renderer and absolute source timestamps. `SoundtrackAnalyzer` also precomputes four band envelopes on the same 10 ms grid. Two-stage crossovers at 123, 552 and 2960 Hz match the renderer's 32-band groups. Each band is normalized against its own 95th-percentile level for the song, so loud passages stay louder than quiet ones, and then follows an 18 ms rise and 95 ms fall. An attack swell runs the 65 ms attack pulse through a 20 ms rise and 250 ms fall. Both are read by time, so every frame stays a pure function of soundtrack time. Native designs use the envelopes and swell for element motion. The released spatial and mesh families now use the swell and the low envelope for their music-driven geometry instead of the raw pulse and instantaneous bass. Every one of these inputs is multiplied by Chaos. `VisualPalette.swift` supplies explicit RGB stops shared by all geometry and shader bindings. Ultraviolet, Electric Candy, Emberlight, Blue Hour and Fernlight use different color ranges; time traverses those stops instead of rotating through the full color wheel. Procedural texture channels are neutral so they do not introduce competing hues. These are authored palettes; asset-catalog inspection did not establish matching native visual palette tables. Soundtrack strobe uses the cached source treble attacks, including hits between rendered frames. Four cascaded high-pass stages reject low-frequency leakage when bass begins. Its source onset detector uses a 35 ms refractory period; the renderer emits a 20 ms white envelope once per new attack. The sensitivity control changes the source-event strength gate. White compositing runs after content blur. Seeking backwards resets the emission history. The older spectral-band gate remains for render inputs without a soundtrack timeline. These gates identify sharp attacks rather than separating instruments; flashes are quantized to the output frame rate. ## Studio `StudioTimeline` stores source start/end times, a visualizer ID, and an optional requested bar count per card. Autocorrelation of source attacks estimates a 60–200 BPM period and phase; without a reliable grid it uses 120 BPM. A cached one-bar segmentation plan supplies beat-aligned endpoints for length changes. Each card’s Bars control ripples later cards while preserving their visualizer order and the untouched prefix. The tail is clipped at the soundtrack’s exact duration; shortened sequences fill the remaining song with the last visualizer and the default cadence. Apply to all offers an opt-in Bars control, assigns that length to every card, and updates the default cadence. Older projects infer missing bar counts from durations and detected BPM. Bar counts are validated as positive integers, stored in project timeline entries, and remain intact during visualizer/style randomization. Detection runs automatically for a new soundtrack or an empty Studio; there is no separate Auto-detect button or boundary dragging interface. The Studio card row uses a fixed-height lazy stack and card indices as view identities, so shifting start times updates existing controls instead of recreating the entire timeline. Timing edits skip audio seeks unless leaving a bounded section preview. Saving an unchanged visual style does not publish a library update or rewrite preset persistence. The Studio regression covers 100 bar edits across 10,000 sections with the entire preset library populated and verifies no preset publications or persistence changes. Sections contain no appearance snapshot. `StudioStore` uses one shared `VisualPreset` per visualizer; the normal appearance controls update that preset. Playback and export select the visualizer at the exact source timestamp, across the entire soundtrack. Export snapshots the shared preset dictionary before rendering and applies it on the first section and each change. Project files store the section list and shared dictionary; older project files remain readable. The whole section card selects its section. `AudioController.selectSection` preserves the playback state: running playback starts a new bounded loop, while paused playback seeks to the section without starting. Re-selecting the running card restarts it without toggling pause; the separate play button still toggles play/pause. Its chevron opens the visualizer modal, which uses full-width rows. Sibling 44-point buttons play the bounded section or randomize its visualizer independently. Section seeks round up to the first source sample inside the boundary, avoiding selection of the preceding section. The audio player schedules only the section’s frames and repeatedly restarts at its first sample, regardless of the whole-track Loop switch. Pause, seek, changing sections, clearing the soundtrack, and full-track presentation invalidate or leave the section loop; generation tokens prevent stale completion callbacks from restarting it. Whole-timeline randomization opens a custom dialog with independent Visualizers and Bar lengths switches (defaults on/off), before pausing playback and applying the selected changes; Cancel performs no mutation or playback action. Visualizers changes only assignments. Bar lengths chooses 1–8 bars per card from the cached one-bar grid, preserves visualizer order, and trims or repeats tail cards to cover the song; it retains the default cadence for future cards. Selecting both rebuilds timing before assigning new visualizers. The same validated, atomic timeline rebuild handles individual, apply-all, and randomized bar changes. All modes retain shared appearance settings. Individual-section shuffle changes only its visualizer ID and retains timing. The exporter always renders the full source soundtrack; legacy project trim fields are ignored on load and omitted on save. Without audio it renders a 15-second silent video. Canvas shape, resolution, and frame rate live in Project settings, including 2160-pixel shorter-edge 4K output, with one toolbar export action. The UI has no boundary drag handles or removal editor. ## Performance sample An optimized Swift build on this development Mac rendered 60 completed GPU frames after five warmup frames, with blur disabled. The earlier renderer at commit `18f52ef` was compared with the current renderer using the same soundtrack spectrum and timestamps. The shader lighting changed in this revision; the timing comparison is of complete frames, not just a geometry microbenchmark. | Resonant Shell frame size | Earlier mean | Current mean | | --- | --- | --- | | 1920 × 1080 | 312.8 ms | 20.5 ms | | 960 × 540 | 311.8 ms | 20.3 ms | | 540 × 960 | 314.1 ms | 12.4 ms | Removing triangle sorting, reducing subdivisions, reserving instance buffers, and reading appearance properties once per field reduced CPU work. Timings vary with scene settings and concurrent load; this sample does not guarantee 60 fps at every size. `test-visual-performance.sh` reproduces the current-frame measurement. See `docs/native-visualizer-validation.md` for the current combined-catalog checks and measured timing. These are development measurements, not a guarantee of real-time 4K60 on every design or Mac. ## Validation Native catalog checks: - `scripts/test-native-expansion.sh`: all offered designs fill at least 14/16 canvas cells in 16:9, 4:3, 3:4, 9:16 and 1:1 at three song positions, using real soundtrack analysis. It also checks that every pair of the active-design comparisons is distinguishable with one palette, times every design at 1080p and 4K, exports a Studio timeline through every new design in wide, phone and square, and exports a 4K60 multi-section clip, then decodes each video and checks frame count, size, rate, soundtrack and black frames. - `scripts/test-native-migration.sh`: every release-era external index (31 onward) resolves to the same preset at the current catalog boundary or above, never to a new native design. Saved styles, timelines, projects and favorites keep their identities. - `scripts/test-chaos.sh` and `scripts/test-store-edition.sh`: zero Chaos is pixel-identical to silence for all 287 active designs (spectrum, pulse, momentum, beat clock, envelopes, swell and strobe) at three zoom speeds in wide and portrait, while motion continues. Each design responds to Chaos on beats and reproduces exact pixels after backwards seeks. - `scripts/native-gallery.sh audit|stills|frames|timing|zoomcheck|beatcheck|covercheck|palcheck`: developer views and checks for continuity, element response, zoom, coverage and palette fidelity. - `scripts/native-reel.sh`: labeled motion reels exported through the Studio exporter with the real soundtrack. `test-blur.sh` checks equal impulse kernels at the centre and near borders, constant-color preservation, no opposite-edge wrapping, and every style for visible softness, deterministic output, and exact restoration at zero. Social export checks decode sharp/blurred movies and compare shared Studio blur with direct output. The renderer tests exercise every scene with base rendering and content blur. `test-canvas-coverage.sh` checks actual GPU pixels for at least 95% span on both axes, more than 5% visible area, and occupancy in at least 14 of 16 canvas regions. It samples every design in landscape and phone proportions, compares motion and deterministic revisit frames, and tests the revised fields at four timestamps with zoom and rotation variations. These thresholds allow intentional empty space between particles while rejecting a small central object. Offscreen tests additionally check deterministic pixels, two canvas proportions, full-frame white flashes, and bass rejection. Audio-sync regression checks use real PCM kick attacks over sustained tones, quiet and right-only stereo, muted live playback, and deterministic seeks. They verify visible non-strobe pulses in every design and inspect every palette render for distinct outputs. Palettes include contrasting accents, so a single frame is allowed to emphasize an accent instead of meeting a monochromatic channel ratio. Chaos checks compare every GPU design with zero and maximum Chaos, require identical output without beats, and verify deterministic revisits and a monotonic source acceleration clock. Export checks decode low/high Chaos movies driven by real PCM attacks. Geometry and export tests cover separate mathematical and video-timeline behavior. These checks establish execution and sampled correctness; they are not a proof over all possible inputs. Display names belong to PulseCanvas and are independent of native symbol names. Stable numeric mode and palette IDs preserve existing project files and per-design presets. The interface uses a video canvas, a single design strip, soundtrack transport, explicit palette swatches, a visual style inspector, and separate Project settings. Zoom speed is saved per visualizer, decoded with a 1.5 default for earlier projects, randomized with appearance settings, and snapshotted for exports. Spatial scenes advance the camera through world-space geometry; the wire meshes translate logarithmic depth coordinates so cells expand outward. Other designs use two exponentially expanding samples with complementary sine-squared weights; each sample resets with zero contribution, avoiding a visible jump. A wider base layer keeps sparse ribbons and particles visible throughout the canvas. Zero bypasses that pass or holds spatial forward position while visual animation continues. The pass runs before the white flash overlay. `scripts/test-zoom.sh` checks every style, zero-speed animation, deterministic restoration, and cycle continuity, plus 3,240 adjacent frame transitions at actual 30/60fps in Octagon Vault, Ink Cyclone and Tidal Glass at early/late timestamps and three zoom speeds; social export checks decode both geometry and mesh movies and compare shared Studio presets with direct exports. Fit canvas and Wire overlay controls have been removed. Legacy project overlay fields are ignored on load and no longer encoded, and randomization cannot enable the retired overlay. `test-organic-pulse.sh` holds animation time fixed and fits global zoom, translation and brightness to actual quiet/hit frames. The remaining differences must show local deformation, increase with Chaos, release exactly, and disappear at zero. MP4 checks freeze procedural speed and compare two real PCM kicks with quiet frames for element, honeycomb and liquid-surface response. The toolbar Random visualizer action and Command–Shift–R select a different design using its saved shared preset (or normal defaults for an untouched design). They retain every saved style setting and soundtrack state. In Studio, they change only the selected section’s visualizer assignment. The visual-style dice button randomizes only the active design’s settings. The horizontal preset row uses an AppKit scroll view with cached title widths and only visible native buttons. Its selection jumps directly to the destination rather than constructing intermediate SwiftUI rows. ProjectM interactive surfaces are capped at a 1,280-pixel longest edge; the Metal compositor scales the frame to the window. Offline render targets keep their selected dimensions. The bundled preset catalog is curated for sustained visible motion and performance. Legacy numeric scene identities accompany retirement metadata so settings and projects remap correctly. Retired effect settings are skipped during migration; affected clips use Octagon Vault without overwriting that visualizer's existing settings or changing segment boundaries. Use at playhead saves the current shared visual settings and replaces only the section containing the current playback time. ProjectM compositing normalizes fragment positions using the destination drawable dimensions, independently of the capped source texture. This fills Retina and full-screen presentation canvases without clamping large portions of the image to the source edges. `scripts/test-projectm-compositor.sh` checks actual GPU quadrant pixels across wide, portrait, and odd-size drawables; exports retain their full-resolution surfaces. MP4 frames are rendered directly into encoder surfaces rather than captured from the screen. ProjectM preset switches start a fresh engine instance in both preview and export, retaining the shared OpenGL context and output surface. This resets feedback, frame counters and audio filter history alongside the local animation clock. Previously, rewinding that clock inside a retained instance produced negative elapsed time and preset progress, corrupting audio response and leaving some later Studio sections black. The chosen frame rate is now set before preset initialization. Repeated frames of a paused preset remain cached, and adjacent sections using the same preset continue its animation. `scripts/test-projectm-transitions.sh` checks actual GPU pixels from a timing-sensitive fixture at 24/30/60 fps, including switches, initialization FPS, paused frames, backwards seeks and zero Chaos. Integration checks decode a 4K/60 MP4 containing consecutive Tangled Weave, Crimson Spark, Temporal Flame and Spiral Helix sections. A separate full-timeline check with the reported soundtrack reproduced completely black Tangled Weave, Temporal Flame and Spiral Helix sections before the fix; all 29 sections had visible sampled frames afterward at 256 × 144. These checks cover the observed switching defect rather than every possible preset/song combination.