Namespace: filters

filters

Filters provide additional shading and post-processing effects to any display object and its children they are attached to.

You attached filters to a display object using its filters array property.

import { Sprite, BlurFilter, HardMixBlend } from 'pixi.js';

const sprite = Sprite.from('myTexture.png');

// single filter
sprite.filters = new BlurFilter({ strength: 8 });

// or multiple filters
sprite.filters = [new BlurFilter({ strength: 8 }), new HardMixBlend()];

Pixi has a number of built-in filters which can be used in your game or application:


For more available filters, check out the pixi-filters repository.

You can also check out the awesome Filter demo to see filters in action and combine them!

Classes

AlphaFilter
BlurFilter
BlurFilterPass
ColorBlend
ColorBurnBlend
ColorDodgeBlend
ColorMatrixFilter
DarkenBlend
DifferenceBlend
DisplacementFilter
DivideBlend
ExclusionBlend
Filter
HardLightBlend
HardMixBlend
LightenBlend
LinearBurnBlend
LinearDodgeBlend
LinearLightBlend
LuminosityBlend
NoiseFilter
PinLightBlend
SubtractBlend

Interface Definitions

AlphaFilterOptions

Options for AlphaFilter

Properties:
Name Type Default Description
alpha number 1

Amount of alpha from 0 to 1, where 0 is transparent

BlurFilterOptions

Options for BlurFilter

Properties:
Name Type Default Description
kernelSize number 5

The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.

quality number 4

The quality of the blur filter.

strength number 8

The strength of the blur filter.

BlurFilterPassOptions

Options for BlurFilterPass

Properties:
Name Type Description
horizontal boolean

Do pass along the x-axis (true) or y-axis (false).

DisplacementFilterOptions

Options for DisplacementFilter

Properties:
Name Type Description
scale number | PointData

The scale of the displacement.

sprite Sprite

The texture used for the displacement map.

FilterOptions

The options to use when creating a new filter.

Properties:
Name Type Description
antialias FilterAntialias | boolean

If true the filter will make use of antialiasing. Although it looks better this can have a performance impact. By default, the filter will detect the antialiasing of the renderer and change this automatically. Definitely don't set this to true if the renderer has antialiasing set to false. As it will antialias, but you won't see the difference.

This can be a boolean or FilterAntialias string.

blendMode BLEND_MODES

optional blend mode used by the filter when rendering (defaults to 'normal')

blendRequired boolean

If this is set to true, the filter system will grab a snap shot oif the are being rendered to and pass this into the shader. This is useful for blend modes that need to be aware of the pixels they are rendering to. Only use if you need that data, otherwise its an extra gpu copy you don't need! (default false)

padding number

the amount of pixels to pad the container with when applying the filter. For example a blur extends the container out as it blurs, so padding is applied to ensure that extra detail is rendered as well without clipping occurring. (default 0)

resolution number

the resolution the filter should be rendered at. The lower the resolution, the more performant the filter will be, but the lower the quality of the output. (defaults to the renderers resolution) Consider lowering this for things like blurs filters

NoiseFilterOptions

Options for NoiseFilter

Properties:
Name Type Description
noise number

The amount of noise to apply, this value should be in the range (0, 1].

seed number

A seed value to apply to the random noise generation. Math.random() is a good value to use.

Type Definitions

BLEND_MODES

Various blend modes supported by Pixi

ColorMatrix

5x4 matrix for transforming RGBA color and alpha

FilterAntialias

The antialiasing mode of the filter. This can be either:

  • on - the filter is always antialiased regardless of the renderer settings
  • off - the filter is never antialiased regardless of the renderer settings
  • inherit - (default) the filter uses the antialias settings of the renderer