phaserjs/phaser/v3-to-v4-migration

Claude Code and agent skill by phaserjs/phaser

Trust tier 3
  • community
  • ext:[{"type":"template","description":"Custom templates for code generation"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Use this skill when migrating a Phaser 3 project to Phaser 4, or when a user asks about breaking changes, API differences, or how to update their v3 code. Covers renderer changes (pipelines to render nodes), FX/masks to filters, tint system, camera matrix, texture coordinates, DynamicTexture, shaders, lighting, removed game objects, and a full migration checklist. Triggers on: migrate, upgrade, v3 to v4, breaking changes, Phaser 3 to 4, migration guide, update from v3.

Install

npx vskill@latest install phaserjs/phaser/v3-to-v4-migration

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as phaserjs/phaser/v3-to-v4-migration.

Phaser v3 to v4 Migration Guide

This guide covers everything you need to change when upgrading a Phaser v3 project to Phaser v4. It is organized from highest-impact changes to smaller details, so you can work through it top-to-bottom.

Related skills: ../v4-new-features/SKILL.md, ../game-setup-and-config/SKILL.md, ../filters-and-postfx/SKILL.md


Table of Contents

  1. Renderer: Pipelines to Render Nodes
  2. Canvas Renderer Deprecated
  3. FX and Masks are now Filters
  4. Tint System
  5. Camera System
  6. Texture Coordinates and GL Orientation
  7. DynamicTexture and RenderTexture
  8. Shader API
  9. GLSL Loading
  10. Lighting
  11. TileSprite
  12. Graphics and Shape
  13. Geometry: Point Replaced by Vector2
  14. Math Constants
  15. Data Structures
  16. Round Pixels
  17. Removed Game Objects
  18. Removed Plugins and Entry Points
  19. Removed Utilities and Polyfills
  20. Spine Plugins
  21. Miscellaneous Breaking Changes
  22. Migration Checklist

1. Renderer: Pipelines to Render Nodes

Phaser v4 contains a brand-new WebGL renderer. The entire rendering pipeline from v3 has been replaced. This is the single biggest change in v4.

What was removed:

The v3 Pipeline system has been removed entirely. Pipelines frequently held multiple responsibilities (e.g. the Utility pipeline handled various different rendering tasks) and each had to manage WebGL state independently, leading to conflicts where one pipeline could break another's assumptions.

What replaced it:

The new RenderNode architecture. Each render node handles a single rendering task, making the system more maintainable. All render nodes have a run method, and some have a batch method to assemble state from several sources before invoking run.

What this means for you:

  • If your game only uses the standard Phaser API (Sprites, Text, Tilemaps, etc.), the new renderer should work transparently.
  • If you wrote custom WebGL pipelines in v3, they will need to be rewritten as render nodes. Use RenderConfig#renderNodes to register custom render nodes at boot.
  • If you accessed WebGLRenderer internals directly, be aware that many internal properties have been removed or restructured:
  • WebGLRenderer.textureIndexes is removed. Use glTextureUnits.unitIndices instead.
  • WebGLRenderer#genericVertexBuffer and #genericVertexData are removed (freeing ~16MB RAM/VRAM). BatchHandler render nodes now create their own WebGL data buffers.
  • WebGLAttribLocationWrapper is removed.
  • Do not make direct WebGL gl calls in a Phaser v4 game. This can change the WebGL state without updating the internal WebGLGlobalWrapper, causing unpredictable behavior. If you need direct WebGL access, use an Extern game object, which resets state after it finishes.

2. Canvas Renderer Deprecated

The Canvas renderer is still available but should be considered deprecated. Canvas rendering does not support any of the WebGL techniques used in v4's advanced rendering features. As WebGL support is effectively baseline today, we recommend WebGL for all new projects.

Canvas retains one advantage: 27 blend modes vs WebGL's 4 native modes (NORMAL, ADD, MULTIPLY, SCREEN). In v4, the new Blend filter can recreate all Canvas blend modes in WebGL, though it requires indirection through a CaptureFrame, DynamicTexture, or similar.


3. FX and Masks are now Filters

This is one of the most impactful changes for v3 users who relied on the FX or Mask systems.

What changed:

FX (pre and post) and Masks have been unified into a single Filter system. A Filter takes an input image and produces an output image, usually via a single shader. All filters are mutually compatible.

Key differences from v3:

  • No more preFX/postFX distinction. Filters are divided into internal (affects just the object) and external (affects the object in its rendering context, usually the full screen) lists.
  • No more object restrictions. In v3, only certain objects supported FX. In v4, filters can be applied to any game object or scene camera, including Extern objects.
  • `BitmapMask` removed. Use the new Mask filter instead. GeometryMask remains available in Canvas only.

Removed derived FX and their replacements:

v3 FXv4 Replacement
BloomPhaser.Actions.AddEffectBloom()
ShinePhaser.Actions.AddEffectShine()
CirclePhaser.Actions.AddMaskShape()
GradientGradient game object

ColorMatrix change:

The ColorMatrix filter shifted its color management methods onto a colorMatrix property:

js
// v3
colorMatrix.sepia();
// v4
colorMatrix.colorMatrix.sepia();

Mask migration:

js
// v3 - BitmapMask
const mask = new Phaser.Display.Masks.BitmapMask(scene, maskObject);
sprite.setMask(mask);
// v4 - Mask filter
sprite.filters.internal.addMask(maskObject);

4. Tint System

The tint system has been overhauled with a new API and additional blend modes.

Removed:

  • tintFill property
  • setTintFill() method

Replacement:

  • Use the new tintMode property or setTintMode() method to control tint blending.
  • Phaser.TintModes enumerates the available modes: MULTIPLY, FILL, ADD, SCREEN, OVERLAY, HARD_LIGHT.

How to convert your code:

js
// v3
sprite.setTintFill(0xff0000);
// v4
sprite.setTint(0xff0000).setTintMode(Phaser.TintModes.FILL);

Other tint changes:

  • tint and setTint() now purely affect color settings. In v3, calling these would silently deactivate fill mode.
  • FILL mode now treats partial alpha correctly.
  • BitmapText tinting now works correctly.

5. Camera System

The camera matrix system has been rewritten. If you only use standard camera properties (scrollX, scrollY, zoom, rotation), your code should work without changes. However, if you access camera matrices directly, you must update your code.

What changed:

v3v4
Camera#matrix = position + rotation + zoomCamera#matrix = rotation + zoom + scroll (no position)
Scroll appended separatelyScroll is part of Camera#matrix
No equivalentCamera#matrixExternal = position only
No equivalentCamera#matrixCombined = matrix * matrixExternal

If you manipulated scroll factors manually:

js
// v3
spriteMatrix.e -= camera.scrollX * src.scrollFactorX;
// v4
TransformMatrix.copyWithScrollFactorFrom(matrix, scrollX, scrollY, scrollFactorX, scrollFactorY);

Other camera changes:

  • GetCalcMatrix() now takes an additional ignoreCameraPosition parameter.
  • GetCalcMatrixResults now includes a matrixExternal property.

6. Texture Coordinates and GL Orientation

Phaser v3 used top-left orientation for textures, which caused mismatches internally (framebuffers drawn upside-down, then flipped). Phaser v4 uses GL orientation throughout, where Y=0 is at the bottom.

Action required:

  • If you use compressed textures, they must be re-compressed with the Y axis starting at the bottom and increasing upwards. This is usually available as a "flip Y" option in your texture compression software.
  • Standard image textures (PNG, JPG, etc.) are handled automatically -- no action needed.
  • If you write custom shaders, note that texture coordinates now use GL conventions where Y=0 is at the bottom of the image.

7. DynamicTexture and RenderTexture

In v3, DynamicTexture allowed you to define batches and perform intricate drawing operations directly. In v4, many of these complex methods have been removed in favor of using the standard rendering system, which handles batching automatically.

Breaking change: DynamicTexture and RenderTexture must now call render() to execute all buffered drawing commands. Previously, draw commands were executed immediately.

New capabilities:

  • DynamicTexture#preserve() keeps the command buffer for reuse after rendering, allowing you to re-render commands that draw changing game objects.
  • DynamicTexture#callback() inserts a callback to run during command buffer execution.
  • DynamicTexture#capture renders game objects more accurately than draw, capturing the current camera view.
  • RenderTexture.renderMode property: "render" (draw like an Image), "redraw" (update texture during render loop without drawing), or "all" (both). The "redraw" mode enables updating textures mid-render-loop for same-frame shader outputs.
  • TextureManager#addDynamicTexture now has a forceEven parameter.

8. Shader API

The Shader game object has been significantly rewritten. Existing v3 shaders will need to be updated.

What changed:

  • The construction signature now takes a config object (ShaderQuadConfig) instead of individual parameters.
  • Shadertoy-style uniforms (resolution, time, etc.) are no longer set automatically. Encode them into your configuration if needed.
  • Texture coordinates now use GL conventions (Y=0 at bottom).
  • New Shader#setUniform(name, value) method for setting program uniforms individually.
  • New Shader#renderImmediate method for rendering outside the regular render loop.

9. GLSL Loading

The way Phaser loads GLSL code has changed:

  • GLSL code is no longer classified as "fragment" or "vertex" when loaded. Under the new system it could be either, or both. You load shaders separately and combine them when creating a Shader.
  • Custom templates have been replaced with #pragma preprocessor directives, which are valid GLSL and compatible with automated syntax checkers. The pragmas are removed before compilation.

10. Lighting

Lighting has been simplified and enhanced.

How to convert your code:

js
// v3 - Pipeline-based lighting
sprite.setPipeline('Light2D');
// v4 - Simple method call
sprite.setLighting(true);

Other lighting changes:

  • Lighting is available on many game objects: BitmapText, Blitter, Graphics, Shape, Image, Sprite, Particles, SpriteGPULayer, Stamp, Text, TileSprite, Video, TilemapLayer, and TilemapGPULayer.
  • Objects can now cast self-shadows using a shader that simulates shadows from surface features based on texture brightness. Configurable game-wide or per-object.
  • Lights now have a z value to set height explicitly, replacing the implicit height based on game resolution from v3.
  • Note: lighting changes the shader, which breaks render batches.
  • You can also use the ImageLight filter for image-based lighting, but it is separate from the core lighting system.

11. TileSprite

TileSprite has been internally rewritten to use a new shader that manually controls texture coordinate wrapping instead of relying on WebGL texture wrapping parameters.

What changed:

  • TileSprite no longer supports texture cropping.
  • TileSprite now assigns default dimensions to each dimension separately.

New capabilities:

  • TileSprite now supports texture frames within atlases and spritesheets (v3 could only repeat the entire texture file).
  • New tileRotation property allows rotating the repeating texture.
  • Works correctly with compressed textures, non-power-of-two textures, and DynamicTextures (all had issues in v3).

12. Graphics and Shape

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
39,633
Repository forks
7,130
7-day trend score
53

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 6 months ago.

Extension points

  • templateCustom templates for code generation

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/phaserjs/phaser/v3-to-v4-migration/badge)](https://verified-skill.com/skills/phaserjs/phaser/v3-to-v4-migration)

Something wrong with this skill or its page? Tell us.