Migration de la version 3 à la version 4
/SKILLUtilisez cette compétence lorsque vous migrez un projet Phaser 3 vers Phaser 4, ou lorsqu'un utilisateur vous pose des questions sur les changements m
name: v3-to-v4-migration
description: "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."
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
- Renderer: Pipelines to Render Nodes
- Canvas Renderer Deprecated
- FX and Masks are now Filters
- Tint System
- Camera System
- Texture Coordinates and GL Orientation
- DynamicTexture and RenderTexture
- Shader API
- GLSL Loading
- Lighting
- TileSprite
- Graphics and Shape
- Geometry: Point Replaced by Vector2
- Math Constants
- Data Structures
- Round Pixels
- Removed Game Objects
- Removed Plugins and Entry Points
- Removed Utilities and Polyfills
- Spine Plugins
- Miscellaneous Breaking Changes
- 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#renderNodesto register custom render nodes at boot. - If you accessed
WebGLRendererinternals directly, be aware that many internal properties have been removed or restructured: WebGLRenderer.textureIndexesis removed. UseglTextureUnits.unitIndicesinstead.WebGLRenderer#genericVertexBufferand#genericVertexDataare removed (freeing ~16MB RAM/VRAM).BatchHandlerrender nodes now create their own WebGL data buffers.WebGLAttribLocationWrapperis removed.- Do not make direct WebGL
glcalls in a Phaser v4 game. This can change the WebGL state without updating the internalWebGLGlobalWrapper, causing unpredictable behavior. If you need direct WebGL access, use anExterngame 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 **e