Skip to content

Migrate simple effects to createEffectComponent - #366

Open
kvvasuu wants to merge 1 commit into
pr2/effect-composerfrom
pr3/simple-effects
Open

Migrate simple effects to createEffectComponent#366
kvvasuu wants to merge 1 commit into
pr2/effect-composerfrom
pr3/simple-effects

Conversation

@kvvasuu

@kvvasuu kvvasuu commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Third PR in the stack (base: pr2/effect-composer).
Migrates every effect whose underlying postprocessing class can be constructed with zero arguments to createEffectComponent from PR1 - ASCII, Bloom, BrightnessContrast, ChromaticAberration, ColorAverage, ColorDepth, Depth, DotScreen, FXAA, Glitch, Grid, HueSaturation, LensFlare, Noise, Pixelation, Ramp, SMAA, Scanline, Sepia, TiltShift, TiltShift2, ToneMapping, Vignette, Water, Texture.

  • Live props (anything with a real setter in postprocessing) now update the existing effect instance directly instead of reconstructing it on every change. Construction-only options (no live setter - e.g. Bloom's mipmapBlur, Glitch's dtSize) are routed explicitly through args, the same way any other r3f element takes construction args.
  • A ref on any of these now points to one stable instance across prop updates, instead of a new instance every reconstructing render.
  • A handful of real bugs found and fixed alongside the migration, not just mechanical porting:
    • opacity was untyped (and, for Pixelation, unforwarded at runtime) on nine of these despite working - or being documented to work - at runtime: Bloom, Noise, SMAA, TiltShift, ToneMapping, Grid, ColorDepth, Glitch, Pixelation.
    • Removing blendFunction/opacity or ColorDepth's bits didn't reset to the effect's real default - both were always forwarded as an explicit prop even when undefined, which defeats r3f's reset-on-removal (present-but-undefined isn't the same as absent). For blendFunction specifically this was worse than cosmetic: r3f's native reset couldn't have recovered the right value regardless, since BlendMode's own constructor requires an argument - it would have fallen back to BlendFunction.SKIP (0), which doesn't pick the wrong blend mode, it hides the effect entirely. Fixed by applying these two through useLiveDefaults instead, same as the hand-rolled effects.
    • ChromaticAberration's radialModulation/modulationOffset props were typed as required - postprocessing's own .d.ts incorrectly marks them so, even though its JSDoc confirms both are optional with defaults.

Covers every effect whose postprocessing class constructs with zero arguments (Bloom, Noise, Vignette, FXAA, and ~20 others) - live props update the existing instance instead of reconstructing on every change, construction-only options move to explicit args. Also fixes a few bugs these effects had on top of the migration: opacity typing on nine of them, ChromaticAberration's radialModulation/modulationOffset incorrectly required, ColorDepth's bits not resetting on removal.
@kvvasuu
kvvasuu force-pushed the pr3/simple-effects branch from e830758 to 8219d39 Compare August 5, 2026 20:30
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