API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classDisplacementFilter
A Filter that offsets every fragment's source position by a direction read out of a texture - heat haze, water refraction, glass, shockwaves and dissolve-style warping. The map's red channel drives the horizontal direction and its green channel the vertical, both decoded from `[0, 1]` to `[-1, 1]`, so flat `(0.5, 0.5)` grey is no displacement at all. The result is scaled by scaleX / scaleY in logical units, which keeps the distortion the same size on screen at every pixel ratio and Filter.resolution. ```ts const haze = new DisplacementFilter({ map: noiseTexture, scale: 12 }); water.filters = [haze]; // Scroll the map from the scene's update to animate the distortion. haze.offsetV -= delta * 0.1; ``` A fragment displaced past the edge of the effect domain has nothing to read and comes out transparent rather than smearing the border. The domain grows by the largest displacement on every side, so a subject at rest keeps the room its distortion needs. Runs on a ShaderFilter carrying both a GLSL and a WGSL source, so it works on either backend without the caller choosing one.
import { DisplacementFilter } from '@codexo/exojs'A Filter that offsets every fragment's source position by a direction read out of a texture - heat haze, water refraction, glass, shockwaves and dissolve-style warping.
The map's red channel drives the horizontal direction and its green channel the vertical, both decoded from `[0, 1]` to `[-1, 1]`, so flat `(0.5, 0.5)` grey is no displacement at all. The result is scaled by scaleX / scaleY in logical units, which keeps the distortion the same size on screen at every pixel ratio and Filter.resolution.
```ts const haze = new DisplacementFilter({ map: noiseTexture, scale: 12 });
water.filters = [haze];
// Scroll the map from the scene's update to animate the distortion. haze.offsetV -= delta * 0.1; ```
A fragment displaced past the edge of the effect domain has nothing to read and comes out transparent rather than smearing the border. The domain grows by the largest displacement on every side, so a subject at rest keeps the room its distortion needs.
Runs on a ShaderFilter carrying both a GLSL and a WGSL source, so it works on either backend without the caller choosing one.
new(options: DisplacementFilterOptionsConstruction-time options for a DisplacementFilter.): DisplacementFilterapply(backend: RenderBackend, input: RenderTextureAn off-screen render target that can also be sampled as a texture. Combines RenderTarget (framebuffer attachment) with the sampler parameters of a Texture (sca…, output: RenderTextureAn off-screen render target that can also be sampled as a texture. Combines RenderTarget (framebuffer attachment) with the sampler parameters of a Texture (sca…, resolution: number): voiddestroy(): voidgetOutputBounds(input: ReadonlyRectangleRead-only view of a Rectangle: every accessor and non-mutating query a rectangle offers, with none of its writers. Returned by APIs that hand out a LIVE intern…, output: RectangleMutable axis-aligned rectangle defined by a top-left origin `(x, y)` and dimensions `(width, height)`. Implements Collidable with full SAT collision response f…): voidinvalidate(): voidsetScale(scale: number | readonly [number, number]): thisresolution: TargetResolutionoffsetU: numberoffsetV: numberscaleX: numberscaleY: number