PokéRogue
    Preparing search index...

    The Displacement Filter Controller.

    This Filter controller manages the displacement effect.

    The displacement effect is a visual technique that alters the position of pixels in an image or texture based on the values of a displacement map. This effect is used to create the illusion of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to characters, objects, or backgrounds to enhance realism, convey movement, or achieve various stylistic appearances.

    This effect samples across an area. To avoid missing data at the edges, use controller.setPaddingOverride(null) to automatically pad game objects, or camera.getPaddingWrapper(x) to enlarge a camera.

    A Displacement effect is added to a Camera via the FilterList component:

    const camera = this.cameras.main;

    camera.filters.internal.addDisplacement();
    camera.filters.external.addDisplacement();

    Hierarchy (View Summary)

    Index
    • Parameters

      • camera: Camera

        The Camera that owns this filter.

      • Optionaltexture: string

        The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'.

      • Optionalx: number

        The amount of horizontal displacement to apply. A very small float number, such as 0.005. Default 0.005.

      • Optionaly: number

        The amount of vertical displacement to apply. A very small float number, such as 0.005. Default 0.005.

      Returns Displacement

    active: boolean

    Toggle this boolean to enable or disable this filter, without removing it from and re-adding it to the Camera's filter list.

    allowBaseDraw: boolean

    If true, this filter will be permitted to draw to the base texture. This can be unwanted if, for example, the filter doesn't actually draw anything.

    This is an internal flag used by the renderer. You should not modify this value directly.

    camera: Camera

    A reference to the Camera that owns this filter.

    currentPadding: Rectangle

    The padding currently being used by this filter. This is read during rendering via getPadding, and may be updated by subclass implementations. It is necessary for filters being used in an external list. You should not modify this value directly.

    ignoreDestroy: boolean

    Whether this filter controller will be destroyed when the FilterList that owns it is destroyed. If you enable this, you must ensure that you clean up the filter controller at an appropriate time. This allows you to reuse a controller for multiple objects; this is not recommended unless you know what you're doing. It tends to work best with external filters.

    paddingOverride: Rectangle

    Padding override. This is on by default. If this is set, the filter will use this padding instead of calculating it. Prefer using setPaddingOverride instead of modifying this directly.

    renderNode: string

    The ID of the RenderNode that this filter uses.

    The underlying texture used for displacement.

    x: number

    The amount of horizontal displacement to apply. The maximum horizontal displacement in pixels is x multiplied by 0.5 times the width of the camera rendering the filter.

    y: number

    The amount of vertical displacement to apply. The maximum vertical displacement in pixels is y multiplied by 0.5 times the height of the camera rendering the filter.

    • Destroys this Controller and nulls any references it holds.

      Returns void

    • Returns the amount of extra padding, in pixels, that this filter requires when rendering. The padding accounts for the displacement effect extending beyond the original bounds of the Camera's rendered output.undefined

      Returns Rectangle

      The padding Rectangle.

    • Returns the rounded padding required for this filter.

      Most filters don't need extra padding, but some may sample beyond the texture boundaries, such as a blur or glow effect.

      The bounds are encoded as a Rectangle. To enlarge the bounds, the top and left values should be negative, and the bottom and right values should be positive.

      This method calls getPadding() to get the raw padding values, and uses Math.ceil() to set the values of paddingOverride and currentPadding.undefined

      Returns Rectangle

      The rounded padding required by this filter.

    • Sets the active state of this filter.

      A disabled filter will not be used.

      Parameters

      • value: boolean

        true to enable this filter, or false to disable it.

      Returns this

      This filter instance.

    • Sets the padding override. If this is set, the filter will use this padding instead of calculating it. Call setPaddingOverride(null) to clear the override. Call setPaddingOverride() to set the padding to 0.

      Parameters

      • Optionalleft: number | null

        The left padding. Default 0.

      • Optionaltop: number

        The top padding. Default 0.

      • Optionalright: number

        The right padding. Default 0.

      • Optionalbottom: number

        The bottom padding. Default 0.

      Returns void

    • Sets the Texture to be used for the displacement effect.

      You can only use a whole texture, not a frame from a texture atlas or sprite sheet.

      Parameters

      • Optionaltexture: string

        The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. Default '__WHITE'.

      Returns this

      This Filter Controller.