LumosLab-Innovation/3D-lab-skills / plugins/threejs-lab/skills/threejs-temporal-surfaces
threejs-temporal-surfaces
VerifiedBuild screen-space temporal surface effects in Three.js. Use for full-resolution touch-history ping-pong, frost and thaw masks, reduced-resolution separable blur, static crystalline structure targets, and two-scale normal-map refraction.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 1.0 KB |
| SKILL.md | skill md | 2.2 KB |
| agents/openai.yaml | config | 311 B |
| references/ping-pong-accumulation.md | markdown | 5.8 KB |
references/ping-pong-accumulation.md
View on GitHub# Touch-history frost accumulation
Use this reference for screen-space frost whose visible mask and refractive response depend on persistent touch history, reduced-resolution scene blur, static crystalline fields, and two-scale normals.
## Contents
- Exact pass graph
- Render-target ownership
- Persistent pointer state
- Frost composite
- Refraction output
- Observed defects and required corrections
- Diagnostic contract
## Exact pass graph
The frame graph owns these targets:
| Target | Resolution | Lifetime | Purpose |
| --- | --- | --- | --- |
| root | display DPR | every frame | source scene |
| vertical blur | `0.4` DPR | every frame | first separable blur axis |
| horizontal blur | `0.4` DPR | every frame | broad blurred source |
| frost composite | display DPR | every frame | scene, blur, structure, interaction |
| pointer read/write | display DPR, half-float | persistent | touched/cleared history plus tilt |
| frost noise | `0.4` DPR | once | coarse crystalline structure |
| frozen noise | display DPR | once | dense frozen structure |
| highlight noise | display DPR | once | highlight breakup |
Per-frame order is fixed:
```text
root scene
-> vertical blur
-> horizontal blur
-> frost composite
-> pointer history write and swap
-> display output samples the new frost target
```
The frost pass therefore reads the pointer state from the previous completed
frame. Preserve that one-frame history relationship unless changing it
deliberately and validating the response.
## Render-target ownership
The single-target helper:
1. stores `renderer.autoClear`;
2. sets the requested clear mode;
3. binds the target;
4. renders;
5. restores the default target;
6. restores `autoClear`;
7. disposes the target on owner teardown.
The double-target helper writes only to `write`, exposes `read.texture` before
the draw, swaps after the draw, and returns the new `read.texture`.
```text
read = completed state
write = destination for this update
render(write, sampling read)
swap(read, write)
```
Both targets resize together. A production adaptation must also define whether
resize preserves, resamples, or clears state. The hook resizes the
targets but does not explicitly clear both histories.
## Persistent pointer state
The pointer target uses:
```text
R = accumulated interaction mask
A = accumulated tilt-response mask
G/B = duplicate R in the output
```
Defaults:
```text
decay per rendered frame = 0.002
noise strength = 0.16
frost-noise strength = 0.10
mask strength = 0.30
radius = 0.15 -> 0.17
corner fade = 0.50 -> 0.60
side fade = 0.00 -> 0.50
```
The update is:
```text
previous = max(previous - decay, 0)
center = pointer * 0.5 + 0.5
distance = aspect-corrected distance to center
deposit = edge-masked noisy radial brush when touching
Rnext = clamp(Rprevious + noisyDeposit, 0, 1)
Anext = clamp(Aprevious + lower-noiseDeposit, 0, 1)
```
The side and corner masks keep a circular deposit from clipping abruptly at
viewport boundaries. The alpha channel deliberately uses a less noisy brush so
device tilt can react smoothly while the visible thaw/frost boundary stays
irregular.
## Frost composite
The frost pass inverts pointer history:
```text
clearAmount = 1 - pointer.R
```
It combines three static structures:
```text
base structure = mix(frozenNoise, highlightNoise, 0.30)
coarse frost = contrast(frostNoise * 1.70 + frostAmount, 1.60)
mask = contrast(base structure + coarse frost * clearAmount, 1.80)
```
The scene treatment is coupled:
```text
blurMix = clamp(clearAmount * (mask + 0.30), 0, 1)
scene = mix(sharpScene, blurredScene, blurMix)
scene *= (0.90, 0.90, 1.03)
saturation *= 1.20
brightness *= 0.70
```
Frost color then mixes:
```text
thin tint = (0.82, 0.86, 1.05)
thick tint = (0.92, 0.96, 1.10)
frost tint strength = 0.70
highlight tint strength = 0.80
```
The composite alpha stores the structural frost mask before the pointer is
applied. The output pass uses that alpha to gate normal-map refraction.
## Refraction output
The final pass samples two mirrored-repeat normal maps in screen coordinates:
```text
main scale size = 1200, strength = 0.30
sub scale size = 350, strength = 2.0
IOR = 1.31
thickness = 1.0
source inset = 0.17
Fresnel strength = 0.80
```
The main map also produces a grayscale height weight for the sub-map. Device
tilt rotates the view vector, with pointer alpha contributing up to `0.8`.
Refraction is mixed only where both frost alpha and the inverse pointer mask
permit it.
## Observed defects and required corrections
Do not preserve these weaknesses silently:
- Pointer decay is per frame, not per second. Convert it to
`1 - exp(-rate * deltaSeconds)` or an equivalent time-based update.
- The alpha-aware blur divides RGB and alpha by `sumW`. Fully transparent
neighborhoods can make `sumW == 0`; guard with an epsilon and define the
transparent result.
- Blur alpha is accumulated with unmodified kernel weights but divided by the
alpha-weighted RGB denominator. Treat RGB normalization and alpha
normalization separately.
- Pointer aspect is assigned from the low-resolution target although pointer
state is high resolution. The ratio is normally equal, but ownership should
use the actual pointer target.
- Static targets opt out of auto-resize. A resize policy must regenerate or
remap them.
- Screen-space state follows the viewport, not the depicted surface. Do not use
this representation for world footprints or object-bound paint.
## Diagnostic contract
Expose:
```text
root scene
vertical blur
horizontal blur
each static noise target
previous pointer R/A
current deposit R/A
next pointer R/A
frost mask before pointer
frost mask after pointer
sharp/blur mix
main and sub refraction offsets
final without refraction
final
```
Add pause and single-step controls. Verify decay at 30, 60, and 120 FPS after
correcting it to time-based behavior.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |