PIXI.filters.DisplacementFilter

class DisplacementFilter extends PIXI.Filter

The DisplacementFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object.

You can use this filter to apply all manor of crazy warping effects. Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y.

The way it works is it uses the values of the displacement map to look up the correct pixels to output. This means it's not technically moving the original. Instead, it's starting at the output and asking "which pixel from the original goes here". For example, if a displacement map pixel has red = 1 and the filter scale is 20, this filter will output the pixel approximately 20 pixels to the right of the original.

Constructor


new PIXI.filters.DisplacementFilter(sprite: PIXI.Sprite, scale: number) → {}
Parameters:
Name Type Attributes Description
sprite PIXI.Sprite

The sprite used for the displacement map. (make sure its added to the scene!)

scale number

<optional>

The scale of the displacement

Summary


Properties from DisplacementFilter

PIXI.Texture
map

The texture used for the displacement map. Must be power of 2 sized texture.

PIXI.Point
scale

Methods from DisplacementFilter

Properties inherited from Filter

boolean
autoFit = true
PIXI.BLEND_MODES
blendMode = PIXI.BLEND_MODES.NORMAL
boolean
enabled

If enabled is true the filter is applied, if false it will not.

boolean
legacy
PIXI.MSAA_QUALITY
multisample

The samples of the filter.

number
padding
number
resolution
PIXI.State
state

The WebGL state the filter requires to render.

Properties inherited from Shader

PIXI.Program
program

Program that the shader uses.

Dict<any>
uniforms

Public Properties


map DisplacementFilter.ts:95
map: PIXI.Texture

The texture used for the displacement map. Must be power of 2 sized texture.

scale DisplacementFilter.ts:55
scale: PIXI.Point

scaleX, scaleY for displacements

Public Methods


apply DisplacementFilter.ts:62
apply(filterManager: PIXI.FilterSystem, input: PIXI.RenderTexture, output: PIXI.RenderTexture, clearMode: PIXI.CLEAR_MODES) → {void}

Applies the filter.

Parameters:
Name Type Description
filterManager PIXI.FilterSystem

The manager.

input PIXI.RenderTexture

The input target.

output PIXI.RenderTexture

The output target.

clearMode PIXI.CLEAR_MODES

clearMode.

Returns:
Type Description
void

Powered by webdoc!