agentleFS
linegellinegel/threejs-complete-set-of-skill/skills/threejs-dynamic-surface-effects/SKILL.md

threejs-dynamic-surface-effects

Skill8 starsChanged 4 months agoISCView on GitHub

State-transition screen-space surface effects for Three.js WebGPU/TSL. Use for persistent touch, frost, or thaw history; full-field or sparse accumulation; static crystalline fields; reduced-resolution blur; or history-gated normal refraction.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When temperature, phase, loading, wetness, contact, or weather drives the appearance, close this local handoff before step 1:

    line 14
  2. Distinctive:

    keep the physical source read-only and give screen history its own appearance version.

    line 24
  3. Distinctive:

    Write one contract for:

    line 38
  4. Very specific:

    Use WebGPURenderer from three/webgpu, call await renderer.init(), and require renderer.backend.isWebGPUBackend === true for this canonical …

    line 90
  5. Very specific:

    Use Fn().compute(...), storageTexture(), and textureStore() for history updates.

    line 112
  6. Distinctive:

    Read resources and r185 execution before allocating or swapping textures.

    line 118
  7. Distinctive:

    Keep scene and working buffers linear/HDR until the single output conversion.

    line 131
  8. Distinctive:

    Use screen-period uniforms as periods.

    line 132
  9. Distinctive:

    Read composite and refraction when either branch is active.

    line 136
  10. Distinctive:

    Read resize, reset, and disposal.

    line 154

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

State-Transition Dynamic Surface Effects

Own viewport-locked appearance history and its composite. Route world/object residue to $threejs-particles-trails-and-effects, weather accumulation to $threejs-rain-snow-and-wet-surfaces, bounded water to $threejs-water-optics, and shared full-frame output decisions to $threejs-image-pipeline.

When temperature, phase, loading, wetness, contact, or weather drives the appearance, close this local handoff before step 1:

  • name the physical quantity and units, producer frame/origin, transform and origin generations, and projection into screen UV;
  • name the source interval, cadence, sample phase, immutable producer/version, and renderer consumer;
  • declare support/filter, validity, staleness, error, and missing-signal policy;
  • bind the GPU resource generation, producing and consuming passes, and completion dependency;
  • keep the physical source read-only and give screen history its own appearance version; reset it on incompatible clock, origin, transform, projection, or resource-generation changes.

Invoke $threejs-choose-skills when feedback or additional system owners are required. The physical owner retains authority; screen-UV history remains renderer-owned appearance state. Then read external appearance signals for local projection and reset rules.

Process

1. Define the state transition and ownership

Write one contract for:

  • each history channel and its dimensionless meaning;
  • the screen-space event shape, timestamp, pressure/strength, and UV origin;
  • evolution terms such as decay, deposition, diffusion, or no change;
  • the state clock, suspension/seek policy, and reset dependencies;
  • the one history writer, composite consumer, and final output owner;
  • any external physical signal and the decorative overlay kept separate from it.

For touch/frost history, a useful split is visible coverage in R and a smoother tilt/refraction response in A; G/B remain unused or explicitly diagnostic. The step is complete when every channel has one equation, writer, unit domain, clock, and consumer.

2. Select update topology

Choose from the state transition rather than the visual theme:

TransitionUpdate topology
Decay, diffusion, or forcing changes most texelsFull-field ping-pong compute
Deposits are sparse and untouched texels are invariantEvent bounds or dirty tiles
Sparse state also decaysTimestamped tiles with analytic catch-up on every visible/filter sample, or materialize every visible tile
Many events overlapBin events to tiles; bound/compact lists or rasterize one aggregate deposit field
State and inputs are unchangedIdle: retain history and dispatch nothing

Diffusion uses a full field or halo-expanded active domain. Read update topologies for overlap cost and diffusion stability. The step is complete when untouched texels evolve exactly as the chosen model requires and idle frames schedule no state work.

3. Make time and event integration invariant

Derive dt from two ordered samples on the same clock. Treat equal samples as zero elapsed time. A missing previous sample, reversal, seek, invalid mapping, or discontinuity follows the declared freeze, reset, analytic catch-up, or bounded-substep policy.

Rasterize timestamped pointer motion as swept capsules with aspect from the history texture. Integrate decay and saturating deposition together so a held pointer and a swept gesture converge independently of render-frame count. Subdivide event intervals only when their pressure or coverage variation exceeds the declared error gate.

Read dt-correct history before implementing decay, deposition, or diffusion. The step is complete when the same timed input yields equivalent history at 30, 60, and 120 Hz and a suspension does not silently discard elapsed evolution.

4. Allocate the ping-pong graph

Use WebGPURenderer from three/webgpu, call await renderer.init(), and require renderer.backend.isWebGPUBackend === true for this canonical path. Route explicit WebGPU-unavailable teaching to $threejs-compatibility-fallbacks. Allocate two renderer-owned StorageTexture histories at the lowest measured extent/format that passes reconstruction and quantization tests. Keep history, scene color, blur intermediates, and static structure fields as separate resources.

Order the graph:

immutable external appearance signals + timestamped UI events
  -> write next history from previous history
  -> publish/swap the completed history generation
single scene pass
  -> optional separable blur at its owned reduced extent
  -> static structure + current history composite
  -> optional history-gated normal refraction
  -> one RenderPipeline output transform

Use Fn().compute(...), storageTexture(), and textureStore() for history updates. Enqueue with renderer.compute(...); r185 computeAsync() is not a GPU-completion fence. Keep the steady path readback-free. Mark/rebuild the render graph when the output node, diagnostic route, resource extent/format, or quality branch changes.

Read resources and r185 execution before allocating or swapping textures. The step is complete when every pass reads a committed generation, no pass samples the texture it writes, and the scene is rendered once.

5. Compose blur, structure, and refraction

Generate static crystalline/noise fields once at startup or when their extent or quality changes. Treat them as data with NoColorSpace. Use separable blur at a pass-owned reduced resolution and alpha-aware normalization when alpha participates. Build the composite and refraction as TSL nodes feeding RenderPipeline.outputNode.

Keep scene and working buffers linear/HDR until the single output conversion. Use screen-period uniforms as periods; derive texel dimensions from the actual resource. Gate refraction by structural coverage and current history, define normal wrap and source-edge behavior, and apply Fresnel in linear light.

Read composite and refraction when either branch is active. The step is complete when blur extent, texture domains, UV conventions, refraction bounds, and output conversion are each owned and visible in diagnostics.

6. Close the lifecycle

Choose one resize policy: clear both histories, remap, or depth/camera-aware reprojection. Reset or reproject on incompatible clock, origin, transform, projection, resource generation, representation, or quality changes. Ordinary continuous source-version advances are sampled rather than reset.

On idle, retain persistent state and stop update work. On resume, apply the declared time policy before accepting new input. On disposal or device loss, invalidate the history generation and release both histories, blur/static resources, compute/pipeline nodes, and input/resize listeners; create a fresh generation before the next draw.

Read resize, reset, and disposal. The step is complete when resize, seek, quality change, idle/resume, disposal, and device loss each have an explicit state transition and resource result.

7. Prove state and presentation

Expose previous history, deposit, next history, dirty tiles/active texels, scene color, blur axes, static fields, pre/post-history mask, refraction offsets, final-without-refraction, and final. Add pause and single-step controls.

Measure event count, tile-list occupancy, dispatched texels, history and intermediate bytes, traffic lower bound, dispatch/draw timing, and whole-frame p50/p95. Scale by stopping idle work, choosing a valid sparse path, then reducing history/blur extent or precision after state-equivalence tests.

Read resource accounting and diagnostics and failure signatures. The skill is complete when timed inputs match across 30/60/120 Hz; full, sparse, and idle transitions behave as selected; ping-pong generations never alias; resize/reset/disposal controls pass; physical inputs remain read-only; the frame loop performs zero history readbacks; the scene renders once; output conversion has one owner; and the complete scene meets its named memory, traffic, and timing budget.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.