Repository navigation
feat(registry): six WebGPU shader backgrounds from the Shaders library - #5138
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Edit accuracy: accurate 2059 (base branch 2059), smooth 1614 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
jrusso1020
left a comment
There was a problem hiding this comment.
Request changes @ c8cb9987. The blocks are wired correctly and the licensing is complete. The blocker is reuse: this vendors the same 1.27 MB library six times.
Blocker (reuse, simpler): six copies of one bundle
- Each
lib/shaders.iife.jsis 1.27–1.28 MB minified, 7.6 MB in total. Their sizes differ by at most 17 KB, so roughly 99% of each file is the sameshaders+typegpuruntime, and only the shader on top differs. - Each installs at its own target (
compositions/<block>/lib/shaders.iife.js), so a user who adds all six gets 7.6 MB in their project too. - The repo already has the pattern for this. The three liquid-glass blocks ship one byte-identical
liquid-glass.iife.js(md5082b0241…in all three) at a shared target,compositions/lib/liquid-glass.iife.js. - The markup is already halfway there: every canvas says which shader it wants (
data-shader="Godrays"), but the driver ignores the value because each bundle hard-codes one shader. - Suggested shape: one bundle with all six shaders that picks by
data-shader, installed atcompositions/lib/shaders.iife.jswith oneTHIRD-PARTY-LICENSES.txt. By the sizes above that's about 1.35 MB instead of 7.6 MB. Ashadersbump then means one rebuild, not six. - Worth doing before merge rather than after, because 7.6 MB of minified text stays in git history for good.
Should-fix: the driver has no source in the repo
The only HyperFrames-written code here is the ~2 KB driver at the end of each bundle. It exists only minified, and nothing records how the bundle was built (entry file, bundler, flags). Please commit the driver source and the build command next to the bundle so it can be reviewed and rebuilt. The liquid-glass bundle has the same gap, so this isn't new, but the driver is ours.
Nits on the driver (from reading the minified tail)
- The frame delta comes from
renderer.__testing.getFrameDiagnostics().globalElapsedTime, which is a test hook. Tracking the last rendered time in the driver (renderSyntheticFrame(t - last); last = t) is simpler and doesn't depend on library internals across a rebuild. data-shader-input(inputsa/b),data-shader-progressand the__render_frame__sibling lookup aren't used by any of the six blocks. If they're meant for later transition blocks, fine; otherwise they're dead weight in every copy.- Not verified (no GPU here): whether a backward seek gives the same frame as a forward one.
renderSyntheticFrametakes a delta, and if any of these shaders keeps smoothing state across frames, Studio scrubbing could drift from the render. Your Metal/software sheet samples forward renders. One check of t=1.5 reached from 0 and from 1.9 would settle it.
What checks out
- Runtime contract: the driver uses the existing TypeGPU adapter (
packages/core/src/runtime/adapters/typegpu.ts) as documented. It listens forhf-seek, hands its render todetail.waitUntil, starts fromwindow.__hfTypegpuTime, and registerswindow.__hf.buildReady.shaders. - No WebGPU: a root that declares
data-requires-webgpufails fast inassertWebGpuAdapterAvailablewith a clear message. Embedded without the root flag, the build promise rejects withshaders: WebGPU unavailable (…), and frameCapture names the rejected key. So it fails loudly rather than rendering black, except in Studio, where the canvas stays black and the console shows the error. The PR's Limits section already states this. - Licensing:
shaders@4.0.0depends only ontypegpu@0.12.3, which depends ontinyest,typed-binaryandtsover-runtime. That is exactly the five entries inTHIRD-PARTY-LICENSES.txt(npm view).license: "Apache-2.0 AND MIT"is right. - Manifests: consistent across all six (tags, 1920×1080, 2 s, three files each, per-block nested targets as most blocks use). All six preview URLs return 200.
- Tests:
registryBlocks.test.tsscans every block directory, so "installs every local script" does cover the new items. Nothing exercises the driver itself. The producer'stypegpu-adapterfixture would be the place for one.
— Rames
c8cb998 to
1a93d4b
Compare
1a93d4b to
686ee57
Compare
686ee57 to
c393d99
Compare
jrusso1020
left a comment
There was a problem hiding this comment.
Approve @ c393d998. This resolves my request for changes at c8cb9987.
Blocker resolved: one bundle
- All six
lib/shaders.iife.jsare byte-identical (md5e5b9e5a4…, 1,306,694 bytes), and so are the six license files. Git stores each as one blob. - Every manifest installs both at the shared
compositions/lib/target, the same as the liquid-glass blocks. driver.jspicks the shader bycanvas.dataset.shaderand throws a named error for an unknown one. The unuseddata-shader-input/-progresspaths are gone.
Should-fix resolved: source and build
registry/blocks/godrays/source/has the driver,build.mjs, a pinned lockfile and a README.- I copied the six
lib/folders to scratch and rannpm ci && npm run build. It reproduced the committed bundle byte for byte in all six blocks, so the minified file is exactly this source plusshaders@4.0.0.
Nits
- Clock hook: your reason for keeping
__testing.getFrameDiagnostics()holds.initialize()advances the clock by one 16 ms frame and no public API reports it. The library is pinned and bundled, and the build fails loudly ifshaders/core/index.jschanges shape. Accepted. - Backward seek: the body reports t=1.5 pixel-identical when reached from 0, from 1.9 and in steps, for all six. I have no GPU, so I didn't re-run it.
Still checks out
registryBlocks.test.tsreads the blocks directory, so it covers these blocks before #5139 adds them toregistry.json. Positive control: dropping the bundle from godrays'filesfails "installs every local script" withgodrays: lib/shaders.iife.js.- The one-shader-per-page limit is no worse than before, since each copy used the same page-wide selector. It is now stated under Limits.
Optional, holistic: nothing guards that blocks sharing a target ship the same bytes. If one copy drifts, a hand edit or a partial rebuild for example, the install order decides which version a project gets, and add keeps an edited file unless --force is passed. A small test could group every block's files[] by target and assert identical content. That would cover the liquid-glass blocks too.
CI had no failures when I checked; some jobs were still running.
— Rames
What
Six 2-second WebGPU blocks built on the MIT Shaders library (
shaders@4.0.0): Godrays, Liquid Metal, Marble, Mesh Gradient, Nebula and Flowing Gradient. Each is taggedwebgpuandwebgpu-shader, declaresdata-requires-webgpu, and has a preview video. Their catalog pages are in #5139, which merges after this.How
lib/shaders.iife.js(1.3 MB), installed atcompositions/lib/shaders.iife.jslike the liquid-glass blocks' shared library. It holds the library, a small driver and only these six shaders; the canvas'sdata-shaderattribute picks one. The six copies are one file in git.registry/blocks/godrays/source/has the driver, the build script, and a lockfile pinning every bundled package.npm ci && npm run buildrebuilds the bundle and copies it into all six blocks.lib/shaders.THIRD-PARTY-LICENSES.txt, installed next to the bundle, carries the verbatim licenses of everything in it:shaders,typegpu,tinyest,typed-binary(MIT) andtsover-runtime(Apache-2.0).licenseisApache-2.0 AND MIT.preview.videopoints at the docs CDN; there is no poster.The driver still reads the library's clock through
__testing.getFrameDiagnostics()rather than tracking the last time itself.initialize()draws one frame and moves the clock by 16 ms before the driver takes over, and no public API reports it. A driver that tracks its own last time renders every frame 16 ms late (measured: up to 0.5/255 off the reference frames, against 0 when reading the clock). The library is pinned and bundled, so this hook cannot change under a published block; a deliberate upgrade rebuilds the bundle and re-checks it.Verification
hyperframes add godraysthenhyperframes add marbleinto one project writecompositions/godrays.html,compositions/marble.htmland one sharedcompositions/lib/. The installed Godrays renders, matching its preview within 1.8/255 (the preview is a 720p encode).hyperframes lint: 0 errors and 0 warnings on each block.oxfmtandoxlintpass on the source.node scripts/check-catalog-source-pr.mjs origin/mainpasses: this PR changes only the six block folders.Not exercised: Studio preview against the render on a GPU. On the GPU-less host, Studio draws these blocks with the software WebGPU flags.
Limits
data-requires-webgpu(it reads the film's own root), so a GPU-less render of that film needs the root to declare it too. On a GPU, nothing changes.Merge order
Merge this, then #5139 right after, with the catalog publish PR held in between: #5139 adds these blocks to
registry/registry.jsonand carries the generator fix their docs players need, and a publish in between would generate payloads with the old generator.