phaser - v4.0.0-rc.4
    Preparing search index...

    The Glow Filter controller.

    This filter controller manages the glow effect for a Camera.

    The glow effect is a visual technique that creates a soft, luminous halo around game objects, characters, or UI elements. This effect is used to emphasize importance, enhance visual appeal, or convey a sense of energy, magic, or otherworldly presence. The effect can also be set on the inside of edges. The color and strength of the glow can be modified.

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

    const camera = this.cameras.main;

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

    Conversion note from Phaser 3:

    • The shader now uses stochastic sampling instead of sampling along straight lines. This improves quality, especially around corners.
    • scale has been added to the parameter list, before knockout.
    • quality is no longer a fraction, but an integer value. The default has changed from 0.1 to 10. This is not a linear conversion, because of the quality improvement. Judge the quality by eye and adjust the value accordingly.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • camera: Cameras.Scene2D.Camera

        The camera that owns this filter.

      • Optionalcolor: number

        The color of the glow effect as a number value. Default 0xffffff.

      • OptionalouterStrength: number

        The strength of the glow outward from the edge of textures. Default 4.

      • OptionalinnerStrength: number

        The strength of the glow inward from the edge of textures. Default 0.

      • Optionalscale: number

        The scale of the glow effect. This multiplies the fixed distance. Default 1.

      • Optionalknockout: boolean

        If true only the glow is drawn, not the texture itself. Default false.

      • Optionalquality: number

        The quality of the glow effect. This cannot be changed after the filter has been created. Default 10.

      • Optionaldistance: number

        The distance of the glow effect. This cannot be changed after the filter has been created. Default 10.

      Returns Glow

    Properties

    active: boolean

    Toggle this boolean to enable or disable this filter, without removing and adding it from the Game Object.

    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.

    A reference to the Camera that owns this filter.

    color: number

    The color of the glow as a number value.

    currentPadding: Geom.Rectangle

    The padding currently being used by this filter. This is set and used during rendering using getPadding. It is necessary for filters being used in an external list. You should not modify this value directly.

    distance: number

    The distance of the glow effect. This cannot be changed after the filter has been created. This controls the distance of the glow effect, in pixels. Integer values only.

    glcolor: number[]

    A 4 element array of gl color values.

    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.

    innerStrength: number

    The strength of the glow inward from the edge of textures.

    knockout: number

    If true only the glow is drawn, not the texture itself.

    outerStrength: number

    The strength of the glow outward from the edge of textures.

    paddingOverride: Geom.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.

    quality: number

    The quality of the glow effect. This cannot be changed after the filter has been created. This controls the number of samples that the glow effect will run for. A higher number is higher quality, but slower to process. Integer values only.

    renderNode: string

    The ID of the RenderNode that this filter uses.

    scale: number

    The scale of the glow effect. This multiplies the fixed distance.

    Methods

    • Returns the padding required for this filter, and sets currentPadding to the result. Most filters don't need extra padding, but some might sample beyond the texture size, such as a blur.

      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.

      Returns Geom.Rectangle

    • 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

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

      Parameters

      • Optionalleft: number

        The top 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