Class: DisplacementFilter

PIXI.filters~DisplacementFilter

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.

new DisplacementFilter (sprite, scale)

Name Type 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

Extends

Members

autoFit boolean inherited overrides

如果启用,PixiJS将使滤镜区域适合边界以提高性能。 如果它不适用于指定的着色器,请将其关闭。

blendMode number inherited overrides

设置滤镜的混合模式

Default Value:
  • PIXI.BLEND_MODES.NORMAL

enabled boolean inherited overrides

如果启用为true,则应用过滤器;如果为false,则不应用过滤器。

legacy boolean readonly inherited overrides

传统过滤器使用属性中的位置和uvs

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

padding number inherited overrides

滤镜的填充。一些滤镜需要额外的空间呼吸运动,例如模糊。 增大此值将为应用滤镜的对象的边界增加额外的宽度和高度。

着色器使用的程序

resolution number inherited overrides

滤镜的分辨率。将此值设置得较低会降低质量,但会提高滤镜的性能。

scale PIXI.Point

scaleX, scaleY for displacements

滤镜需要渲染的WebGL状态

uniforms object readonly inherited overrides

着色器uniform统,uniformGroup.uniforms 的快捷方式

Methods

apply (filterManager, input, output, clearMode) overrides

Applies the filter.

Name Type Description
filterManager PIXI.systems.FilterSystem

The manager.

input PIXI.RenderTexture

The input target.

output PIXI.RenderTexture

The output target.

clearMode PIXI.CLEAR_MODES

clearMode.