Repository navigation
[KS] Motion: shader effects and particles (#405) - #442
Merged
Merged
Conversation
This was referenced Oct 13, 2026
MotionShader: a MotionView with a built-in ripple (CITorusLensDistortion), distortion (CIBumpDistortion), specular sweep (gradient overlay) or dissolve (a precompiled Metal noise-threshold mask rendered on display frames). Each effect is one engine property, installed only while it shows or animates. The Metal library is compiled ahead of time (bun run motion:shaders, Metal 2.0) into a header that records the source and library hashes and the compiler; no user-supplied shader source. Availability builds the pipeline; devices added, removed or lost make it check again. Display frames are skipped rather than waiting for a drawable, and the link follows one animating view, made again when it stops or moves. MotionEmitter with startParticles/stopParticles: a CAEmitterLayer with a 1,000-particle budget (checked in JavaScript and natively), laid out on resize, paused in hidden windows, stopped on unmount and when Reduce Motion turns on (unless started with play). Reduce Motion: ripple, distortion and sweep jump (fade alternate), dissolve fades, particles do not emit. Windows is typed unsupported (#237). MotionShape, MotionMaterial, MotionShader and MotionEmitter pass their content to useMotionView the same way. Adds the Kitchen Sink Shaders and particles screen (localized title and summary), checks, flows, at-rest goldens, and CARenderer-rendered frozen virtual-clock frames in the native coordinator test.
sethwebster
force-pushed
the
seth/ks-405-shaders
branch
from
October 13, 2026 03:01
ec6b09e to
8648c6a
Compare
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #405
What
MotionShader(aMotionViewwith one built-in effect) andgetShaderEffectAvailability. Each effect is one engine property (rippleProgress,distortion,specularProgress,dissolveProgress), so it interrupts, reduces, records and works with the virtual clock like any other property.CITorusLensDistortionlayer filter; distortion:CIBumpDistortion; specular sweep: aCAGradientLayeroverlay. These are baked into Core Animation keyframes, so the app does no work per frame.CAMetalLayermask. A precompiled shader renders it on a display link that only runs while it animates in a visible window. It skips frames when the window is hidden or the view is hidden or offscreen, and renders on virtual-clock advances. Nothing is allocated per frame except Metal's own command buffer and encoder. Device removal or a failed command buffer rebuilds the Metal objects; with no device the API reportshost-restriction/E_UNAVAILABLE.SparkMotionShaders.metalis compiled ahead of time withbun run motion:shadersintoSparkMotionShaders.metallib.h;tests/motion-shaders.test.tschecks it matches the source hash. Apps, the podspec and CI never compile Metal.MotionEmitter,startParticles(durationMsbursts),stopParticles,getParticleAvailability: aCAEmitterLayercapped at 1,000 live particles per emitter. It pauses in hidden windows and stops on unmount or window close.played: "none") unlessreducedMotion: "play".motion-system/shaders.yaml, visual/audit/windows flows updated.docs/motion.md#shader-effects-and-particles. It covers the renderer choice per effect, budget notes for the M1 8 GB reference (design bounds, not measured on that Mac; developed on an M4 Max), and what captures cannot show.Captures
Driver captures (
cacheDisplayInRect:) draw the sweep and the dissolve's rest states. They do not draw the Core Image filters, the Metal mask mid-dissolve, or particles. Flows check those through engine values, and goldens are at rest.tests/motion-coordinator.native.mmrenders frozen virtual-clock frames of ripple, distortion and dissolve withCARenderer, which does draw filters and Metal layers.Review fixes (after rebasing onto #439)
Verification (run in this session on the rebased head, on an M4 Max with the display asleep)