Phaser 4 Filters and Post-FX
Quick Start
Add a glow effect to a sprite:
Add a blur to the camera:
Core Concepts
How Filters Work in v4
Filters are GPU-based post-processing effects applied after an object or camera renders to a texture. Each filter runs a shader pass over that texture, producing the final visual output. Filters are WebGL only.
The rendering pipeline for a camera with filters:
- Objects render to a texture the size of the camera.
- Internal filters process that texture, applying effects in object/camera local space.
- The texture is drawn to a context-sized texture, applying camera transformations (position, rotation, zoom).
- External filters process that context texture, applying effects in screen space.
- The final texture is composited into the output.
Internal vs External Filters
Every FilterList exposes two sub-lists: filters.internal and filters.external. The distinction controls when the filter runs relative to the camera/object transform:
- Internal -- applied before the camera transform. Effects operate in the object's local coordinate space. A horizontal blur on a rotated object appears rotated with the object. Internal filters only cover the object/camera region, so they are cheaper.
- External -- applied after the camera transform. Effects operate in screen space. A horizontal blur on a rotated object always blurs horizontally on screen. External filters are full-screen and more expensive.
Use internal filters wherever possible for better performance.
FilterList
FilterList (Phaser.GameObjects.Components.FilterList) is the container that holds filter controllers. It provides:
add(filter, index)-- add a Controller instance at an optional indexremove(filter, forceDestroy)-- remove and destroy a filterclear()-- remove and destroy all filtersgetActive()-- return all filters whereactive === truelist-- the raw array of Controllers (safe to reorder)- Convenience factory methods:
addBlur(),addGlow(),addMask(), etc.
Filter Controllers
Every filter is a Phaser.Filters.Controller subclass. Common Controller properties:
Key methods: setActive(bool), setPaddingOverride(left, top, right, bottom), getPadding(), destroy().
Enabling Filters on Game Objects
Cameras have filters available by default. Game objects do not -- you must call enableFilters() first:
enableFilters() creates an internal filterCamera on the game object that handles rendering the object to a texture for filter processing. It returns this for chaining.
Related properties on game objects after enabling:
Use willRenderFilters() to check if any active filters will actually render.
Common Patterns
Adding Filters to Game Objects
Camera Filters
Chaining Multiple Filters
Filters execute in list order. Each filter receives the output of the previous one:
Masks via Filters
Masks in v4 are implemented as filters. They use the alpha channel of a texture or game object to control visibility:
Internal masks match the object being filtered. External masks match the camera context. Use a viewCamera parameter to control which camera renders the mask game object.
Wipe / Reveal Transitions
ParallelFilters (Custom Bloom and Compositing)
ParallelFilters splits the input into two paths, processes each independently, then blends the results. This replaces the dedicated Bloom filter from v3:
CaptureFrame for Scene-Level Effects
CaptureFrame captures the current render state at the point it appears in the display list. Objects rendered before it are captured; objects after it are not:
All Built-in Filters
API Quick Reference
Enabling and Accessing Filters
FilterList Methods
Controller Common API
Mask Filter API
ColorMatrix Presets
Gotchas
-
WebGL only -- Filters do not work in Canvas renderer.
enableFilters()returns early if WebGL is not available. -
enableFilters() required for game objects -- Cameras have filters by default. Sprites, images, containers, and other game objects require
enableFilters()before accessingfilters. -
Performance cost -- Each object with active filters creates extra draw calls (one for the base render plus one per active filter). Use sparingly and performance test early.
-
Internal vs external matters -- Internal filters are cheaper (object-region sized). External filters are full-screen. A blur that should rotate with the object must be internal; a blur that should stay screen-aligned must be external.
-
Filter order matters -- Filters are applied sequentially in list order. The output of one feeds into the next.
-
Glow quality and distance are immutable --
qualityanddistanceon the Glow filter cannot be changed after creation. Destroy and recreate the filter to change them. -
CaptureFrame requires forceComposite -- The camera must have
setForceComposite(true)or otherwise render into a framebuffer for CaptureFrame to work. -
Padding for expanding effects -- Filters like Blur, Glow, and Shadow can automatically calculate padding to expand the render texture. Override with
setPaddingOverride()if needed. Passnullto clear the override. When used on a camera, usecamera.getPaddingWrapper(x)to render more world outside the image edge. -
Controller reuse -- By default, controllers are destroyed when their FilterList is destroyed. Set
ignoreDestroy = trueto reuse a controller across multiple objects, but you must manage its lifecycle manually. Works best with external filters. -
Mask game object rendering -- When using a game object as a mask source, it is rendered to a DynamicTexture each frame (if
autoUpdateis true). SetautoUpdate = falseand useneedsUpdate = truefor one-shot updates to improve performance for static masks. -
No Bloom filter -- v4 does not have a dedicated Bloom filter. Use ParallelFilters with Threshold + Blur + ADD blend instead (see Common Patterns), or use
Phaser.Actions.AddEffectBloomto automate the process.
v4 Changes from v3
Source File Map
Related: sprites-and-images.md, cameras.md, v4-new-features.md


