campdotdev/shaders#264shaders

feat(shaders): add FlutedGlass

Describes commit 84cc417

Written after the fact from the diff, without the session’s reasoning.

2 files 92 lines added, 0 removed0 of 2 files reviewed

  • packages/shaders/src/components/fluted-glass/fluted-glass.tsx
  • packages/shaders/src/components/index.ts

6 files 95 lines added, 0 removed0 of 6 files reviewed

  • apps/docs/src/app/components/demo-registry.tsx
  • apps/docs/src/content/components.ts
  • apps/docs/src/content/taxonomy.ts
  • apps/docs/src/app/components/fluted-glass/scene.tsx
  • apps/docs/src/app/components/fluted-glass/params.ts
  • apps/docs/src/app/components/fluted-glass/demo.tsx

2 files 96 lines added, 0 removed0 of 2 files reviewed

  • packages/shaders/src/primitives/flute-surface/flute-surface.ts
  • packages/shaders/src/engine.ts

1 file 48 lines added, 0 removed0 of 1 file reviewed

  • packages/shaders/src/primitives/flute-surface/flute-surface.ts

1 file 90 lines added, 0 removed0 of 1 file reviewed

  • packages/shaders/src/primitives/flute-surface/flute-surface.ts

1 file 95 lines added, 0 removed0 of 1 file reviewed

  • packages/shaders/src/components/fluted-glass/shader.tsx

2 files 67 lines added, 0 removed0 of 2 files reviewed

  • packages/shaders/src/primitives/flute-surface/flute-surface.ts
  • packages/shaders/src/components/fluted-glass/shader.tsx

1 file 46 lines added, 0 removed0 of 1 file reviewed

  • packages/shaders/src/components/fluted-glass/shader.tsx

1 file 87 lines added, 0 removed0 of 1 file reviewed

  • packages/shaders/src/components/fluted-glass/shader.tsx

3 files 76 lines added, 0 removed0 of 3 files reviewed

  • apps/docs-tests/visual/fluted-glass.spec.ts
  • apps/docs-tests/visual/fluted-glass.spec.ts-snapshots/fluted-glass-default-chromium-linux.png
  • apps/docs-tests/visual/fluted-glass.spec.ts-snapshots/fluted-glass-default-chromium-darwin.png

Also changed

The pull request changes these files too. No step shows them.

  • .changeset/fluted-glass.md added 16 lines added, 0 removed
  • GLOSSARY.md modified 18 lines added, 0 removed
  • apps/docs/public/posters/fluted-glass.jpg after the changeapps/docs/public/posters/fluted-glass.jpg added Binary
  • apps/docs/public/posters/fluted-glass.thumb.webp after the changeapps/docs/public/posters/fluted-glass.thumb.webp added Binary
  • apps/docs/src/app/dev/fluted-glass-benchmark/benchmark-scene.tsx added 75 lines added, 0 removed
  • apps/docs/src/app/dev/fluted-glass-benchmark/page.dev.tsx added 12 lines added, 0 removed
  • apps/docs/src/app/dev/fluted-glass-probe/page.dev.tsx added 11 lines added, 0 removed
  • apps/docs/src/app/dev/fluted-glass-probe/probe-scene.tsx added 76 lines added, 0 removed
  • docs/adr/0004-effects-resample-by-wrapping-the-sampler.md added 16 lines added, 0 removed
  • packages/shaders/src/components/fluted-glass/fluted-glass.test.tsx added 274 lines added, 0 removed
  • packages/shaders/src/primitives/flute-surface/flute-surface.test.ts added 53 lines added, 0 removed
  • scripts/build-posters.sh modified 10 lines added, 2 removed

Overview

Why

The Composable card on the homepage, tracked in SHA-217, stacks a Source, FlutedGlass, and Grain in one live scene. Shaders had no glass Effect to put in the middle. This pull request adds the FlutedGlass core that the card needs.

Behavior change

<FlutedGlass /> is a new Effect. Mount it after a Source inside a <ShaderScene>, and you see that Source through vertical strips of glass, 40 CSS pixels wide. Each flute shows a squeezed copy of the image beneath it. A highlight runs down the wall that faces the light, which comes from the upper left, and a soft shadow sits in each groove. Eight props set the glass and the light, and every prop except highlightColor takes a static value or an animation signal.

The engine exports fluteSurface, so a Mode 2 shader can bend and light its own texture with the same math. The docs site has a FlutedGlass page, in a new Warp group under Effects.

Checks

These are the checks that the pull request and its CI report:

  • Every CI job passed on the head commit, including unit tests and visual regression.
  • The component's unit tests check that FlutedGlass registers one UV warp and one color transform, survives Strict Mode, and takes new prop values without registering either pass again.
  • The fluteSurface unit tests check only that it builds its nodes from numbers, from nodes, and from values out of range. The pixel checks test its output.
  • The visual-regression spec compares the docs page's canvas with the fluted-glass-default baselines. Five pixel checks on a stripe probe test the bend, the highlight, the shadow, inert glass, and a transparent scene.
  • ShaderMonitor on /dev/fluted-glass-benchmark timed the GPU at 485×308 CSS pixels and 2x, on an M1 Max in headless Chromium on WebGPU. MeshGradient alone took 0.24 ms, and MeshGradient under the glass took 0.28 ms. The glass adds 0.04 ms against a 0.2 ms budget. Each figure is the median of three loads.

Not covered

  • A UV warp mounted before FlutedGlass, such as Dither's, hands the glass a coordinate it already moved. The bend and the light then read the surface at slightly different points. SHA-267 changes how UV warps stack.
  • FlutedGlass bends only what Sources drew, so glass mounted after Grain leaves the grain unbent. ADR 0002 accepted that limit for every UV warp.
  • FlutedGlass has no color split or blur yet. ADR 0004 decides how they will sample the scene.
  • FlutedGlass works only in Mode 1. Mode 2 gets the fluteSurface primitive and no component.