Skip to content

65 gradient: the Gradient lab (ShaderGradient port in the background layer) - #469

Open
AlexZ005 wants to merge 2 commits into
feat/65from
feat/65-gradient
Open

AlexZ005 wants to merge 2 commits into
feat/65from
feat/65-gradient

Conversation

@AlexZ005

Copy link
Copy Markdown
Collaborator

65 gradient: the Gradient lab

A port of the ShaderGradient look (github.com/ruucm/shadergradient, MIT) inside the M2 background layer. The GLSL is ported to plain three.js; the React package is not used.

What it adds

  • gradientLab shader node (Background group). It samples an offscreen target that a lazy chunk draws (src/lib/gradientLab.js, 9.8 KB, loaded only when a background uses the node). src/lib/gradientLabCore.js holds the pure rules: param schema, camera, synced clock, budget tiers, randomize, Copy as preset.
  • Shapes ribbon / sphere / water with the ported noise displacement; 3 colours; ambient or procedural-environment lighting; reflection; camera azimuth/polar/distance/zoom; speed. Grain is a port of upstream's halftone dot screen on the high tier and a one-sample hash grain on lower tiers.
  • Gradient lab panel in Configure Scene ▸ Background: shape, 3 colours, speed, density, strength, grain, Randomize and Copy as preset. A drag or a colour pick is one undo step. Writes go into the background document, so they replicate, save and undo like any other background edit.
  • Preset index rows gain optional family + needs. The loader drops rows that need a node this build lacks, and the picker lists the family as "Gradient · Name". The presets are in packs#21.
  • Determinism: the picture is a function of params + the shared clock + the target size, so two peers draw the same frame.
  • Budget: VR and reduced motion show a still frame at t = 0, redrawn only on a param or size change. Phones use the low tier (coarser mesh, target ≤ 640, every 2nd frame).
  • Licences: src/lib/LICENSE-shadergradient.txt (ShaderGradient + webgl-noise MIT texts) and a third-party-notices VENDORED entry.

Gates

  • npm run build rc=0; check-ratchet 299/39 = baseline; check:tokens / storage / zindex clean.
  • vitest: 210 files, 2625 tests pass (new tests/unit/gradientLab.test.js, 17).
  • New suite gradient-lab (in battery.json): ALL PASS.
    • every preset draws, is stable on a held clock and changes with time;
    • panel: shape + framing, colour, slider, undo, Randomize, Copy as preset round trip; axe shows 0 serious/critical;
    • reduced motion: still, with exactly one redraw per edit;
    • two peers: same hash on one clock, and A's edit reaches B;
    • N6 folded/unfolded on the low tier;
    • Quest IWER probe: still sphere, 0 redraws, 38 calls / 22.5k tris + 33k lab tris.
  • 65-visuals suites on this branch: background-layer 58, background-presets 81 (now also checks the Gradient family and validates the lab programs with glslangValidator), flow-background 5, fluid-layer 26, visuals-xr-iwer 19, visuals-two-peer 17.
    • visuals-two-peer 2.1 is intermittently red on the unchanged base too (A/B on ad19a01). It reads draw before B's next tick.

🤖 Generated with Claude Code

AlexZ005 and others added 2 commits October 25, 2026 10:39
Gradient lab: a ShaderGradient port (MIT, GLSL ported to plain three.js) as a
gradientLab background node sampling a lazily drawn offscreen target; ribbon,
sphere and water shapes; panel with Randomize and Copy as preset; static in VR
and with reduced motion; index rows gain family + needs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…two peers, N6, Quest probe)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant