DevTools Logo

SVG Displacement Filter Lab

SVG Displacement Filter Lab

Design deterministic SVG turbulence and displacement filter chains locally.

Runs in your browser

Chain: turbulence → displacement → blur → colorMatrix. Seeded turbulence keeps the output deterministic.

Try an example

Filter parameters

Preview

7 lines · 551 chars
FILTER LAB

Details

Design seeded SVG filters with glass, water wave, glitch, and paper texture presets, then copy the generated SVG defs.

    Examples

    Water preset filter

    Input
    generateSvgFilter(getSvgFilterPreset("water"))
    Output
    "<filter id=\"displacement-filter\" ...><feTurbulence .../></filter>"

    Emits feTurbulence, feDisplacementMap, feColorMatrix, and feGaussianBlur in the water chain order.

    Seed determinism

    Input
    generateSvgFilter({ ...getSvgFilterPreset("glass"), seed: 5 })
    Output
    "... seed=\"5\" ..." (identical on every run)

    Same options always produce byte-identical XML; changing the seed changes the noise field.

    About this tool

    SVG Displacement Filter Lab builds gooey distortion filters with generateSvgFilter(options): feTurbulence (fractalNoise or turbulence with baseFrequency, numOctaves, seed) feeds feDisplacementMap (scale plus xChannelSelector/yChannelSelector), then optional feGaussianBlur and feColorMatrix saturate/hueRotate stages run in the order given by chain.

    Presets come from getSvgFilterPreset (glass, water, glitch, paper) via SVG_FILTER_PRESETS — each preset pins baseFrequency, scale, channel selectors, and chain order, and validateSvgFilterOptions rejects non-positive baseFrequency values, numOctaves outside 1–16, empty or duplicated chain steps, and invalid filterId XML identifiers.

    Output is deterministic and client-side: the same options (including seed) always emit byte-identical <filter> XML with named intermediate results (noise, displaced, blurred, saturated, colored).

    How to use this tool

    1. Pick a preset

      Call getSvgFilterPreset with glass, water, glitch, or paper, then tweak scale, seed, or blur on the returned copy.

    2. Set turbulence

      Choose baseFrequency (number or [x, y] pair), numOctaves from 1 to 16, and a seed — identical seeds give identical noise.

    3. Order the chain

      List each of turbulence, displacement, blur, and colorMatrix at most once in chain; primitives emit in that order.

    4. Paste the filter

      Copy the returned <filter> XML (default id displacement-filter, or your own filterId) into an SVG defs block.

    Use cases

    Designing frosted-glass cards

    Use the glass preset's low scale and slight blur for readable backdrop distortion.

    Prototyping liquid hover effects

    Raise scale on the water preset to preview gooey image warps before hand-tuning.

    Adding glitch accents

    Apply the high-scale glitch preset to headings for RGB-split style distortion.

    Common mistakes

    Mistake:Passing zero or negative baseFrequency.

    Fix:Every frequency component must be finite and greater than zero — values like 0 or [0.2, -1] throw.

    Mistake:Repeating a step in chain.

    Fix:Each of turbulence, displacement, blur, and colorMatrix may appear at most once; duplicates throw.

    Mistake:Using an invalid filterId with spaces.

    Fix:filterId must match XML identifier rules (letters, digits, _, -, ., :); the default displacement-filter is used when blank.

    Frequently asked questions

    What does this tool do?

    It builds SVG distortion filters with generateSvgFilter — feTurbulence plus feDisplacementMap with optional blur and colorMatrix stages — and ships glass, water, glitch, and paper presets via getSvgFilterPreset.

    How do seed and baseFrequency change the output?

    baseFrequency sets the noise grain (a number or [x, y] pair, all components finite and positive); identical seeds emit byte-identical XML while a new seed reshapes the noise field.

    Is my artwork uploaded or stored?

    No. Preset math, validation, and XML generation run entirely in your browser.

    Why did my options throw?

    Non-positive baseFrequency, numOctaves outside 1–16, empty or duplicated chain steps, and invalid filterId values throw — check the baseFrequency message first.

    References & standards