Skip to content

Migrate hand-rolled effects to useLiveDefaults - #367

Merged
kvvasuu merged 1 commit into
v4from
pr4/hand-rolled-effects
Aug 9, 2026
Merged

Migrate hand-rolled effects to useLiveDefaults#367
kvvasuu merged 1 commit into
v4from
pr4/hand-rolled-effects

Conversation

@kvvasuu

@kvvasuu kvvasuu commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fourth PR in the stack (base: pr3/simple-effects).
Migrates the effects that can't use createEffectComponent because their postprocessing class requires real constructor arguments (scene/camera/etc., so new EffectClass() doesn't work with zero arguments) - Outline, SelectiveBloom, ShockWave, GodRays, DepthOfField, SSAO, LUT, N8AO. These stay hand-built with useMemo, but now apply live props through useLiveDefaults instead of reconstructing the whole effect on every change.

This is where nearly every real runtime bug found during review lived - kept as its own PR deliberately, not diluted with PR3's more mechanical changes:

  • SSAO's color, fade, minRadiusScale, and world* proximity/distance thresholds didn't reset to SSAOEffect's real constructor defaults on removal - they were being forwarded to the constructor and tracked live, so the live tracker's "default" snapshot captured whatever was passed on the first render instead of the library's true default.
  • DepthOfField's depthTexture was construction-only (any change reconstructed the whole effect, render targets and passes included) despite DepthOfFieldEffect.setDepthTexture() existing specifically to update an existing instance. Now applied live.
  • GodRays (swapping sun) and N8AO (config/quality changes) mutate their effect directly, outside r3f's reconciler, so nothing was ever calling invalidate() - both now correctly repaint under <Canvas frameloop="demand">.

@kvvasuu
kvvasuu force-pushed the pr4/hand-rolled-effects branch from 89dfefb to 8a776a9 Compare August 5, 2026 20:30
@kvvasuu
kvvasuu force-pushed the pr4/hand-rolled-effects branch from 8a776a9 to 991a63c Compare August 9, 2026 13:30
@kvvasuu
kvvasuu force-pushed the pr4/hand-rolled-effects branch from 991a63c to 74ff545 Compare August 9, 2026 13:33
Base automatically changed from pr3/simple-effects to v4 August 9, 2026 13:34
Outline, SelectiveBloom, ShockWave, GodRays, DepthOfField, SSAO, LUT, and N8AO all need real constructor args (scene/camera/etc.), so they stay hand-built with useMemo, but now apply live props through useLiveDefaults instead of reconstructing on every change.

This is where nearly every real runtime bug from review surfaced: a first-apply bug where a still-correct value's setter fired anyway (Outline's multisampling disposing its render target before first use - the actual reason several of these didn't render at all), SSAO's color/fade/minRadiusScale/world* thresholds not resetting on removal, DepthOfField's depthTexture reconstructing instead of using the live setDepthTexture, and GodRays/N8AO not invalidating on live changes under frameloop="demand".
@kvvasuu
kvvasuu force-pushed the pr4/hand-rolled-effects branch from 74ff545 to cc588f4 Compare August 9, 2026 13:34
@kvvasuu
kvvasuu merged commit fca336d into v4 Aug 9, 2026
@kvvasuu
kvvasuu deleted the pr4/hand-rolled-effects branch August 9, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant