옵션
집 Skill 기타 v4-new-features

v4-new-features

phaserjs/phaser phaserjs/phaser

Phaser 4에 추가된 새로운 기능, 게임 오브젝트, 컴포넌트 및 렌더링 기능을 학습할 때 이 스킬을 활용하세요. 필터(Filters), 렌더노드(RenderNodes), 캡처프레임(CaptureFrame), 그라디언트(Gradient), 노이즈(Noise), 스프라이트 GPU 레이어(SpriteGPULayer), 타일맵 GPU 레이어(TilemapGPULayer), 라이팅 컴포넌트(Lighting component), 렌더스텝(RenderSteps) 및 새로운 틴트 모드를 다룹니다. 트리거: v4의 새로운 기능, Phaser 4 기능, RenderNode, SpriteGPULayer, CaptureFrame, Gradient 게임 오브젝트, Noise 게임 오브젝트, 새로운 틴트 모드. v3 코드를 v4로 마이그레이션하는 방법은 v3-to-v4-migration 스킬을 참조하십시오.

...모든 것을 확장하십시오
62
업데이트 된 시간 2026년 8월 4일

Phaser 4의 새로운 기능

Phaser 4의 새로운 기능 및 성능: 필터(FX/BitmapMask 대체), 렌더 노드(파이프라인 대체), CaptureFrame, Gradient, Noise 게임 오브젝트, SpriteGPULayer, TilemapGPULayer, 라이팅 컴포넌트, RenderSteps 및 새로운 틴트 모드.

관련 기술:../v3-to-v4-migration/SKILL.md, ../filters-and-postfx/SKILL.md, ../game-object-components/SKILL.md, ../tilemaps/SKILL.md

v3에서 마이그레이션 중이신가요? 단계별 코드 변경 사항, 제거된 API 및 마이그레이션 체크리스트는 v3에서 v4로 마이그레이션 가이드를 참조하세요.

개요: v4에서 변경된 사항

Phaser 4는 WebGL 렌더링 엔진을 완전히 개편한 버전입니다. v3 렌더러는 각 하위 시스템이 WebGL 상태를 독립적으로 관리하도록 허용하여 충돌을 일으켰습니다(예: 특정 FX가 마스크를 무효화하는 경우). v4는 RenderNode 그래프를 통해 WebGL 상태 관리를 중앙 집중화하며, 각 노드는 정확히 하나의 렌더링 작업만 처리합니다.

주요 제거 항목

주요 추가 기능

  • 새로운 GameObject: CaptureFrame, Gradient, Noise, NoiseCell2D/3D/4D, NoiseSimplex2D/3D, SpriteGPULayer, Stamp, TilemapGPULayer
  • 새로운 컴포넌트: Lighting, RenderSteps, RenderNodes
  • 새로운 틴트 모드: MULTIPLY, FILL, ADD, SCREEN, OVERLAY, HARD_LIGHT
  • 새로운 필터: Blend, Blocky, CombineColorMatrix, GradientMap, ImageLight, Key, Mask, NormalTools, PanoramaBlur, ParallelFilters, Quantize, Sampler, Threshold
  • GL 방향: v4는 표준 GL 방향(텍스처의 경우 Y=0이 하단)을 사용합니다

필터 시스템 (FX 및 BitmapMask 대체)

전체 참조: filters-and-postfx.md

필터는 v3의 FX 및 마스크 시스템을 통합합니다. 모든 필터는 입력 이미지를 받아 셰이더 패스를 통해 출력 이미지를 생성합니다. 필터는 모든 게임 오브젝트나 카메라에 적용할 수 있습니다. v3에서는 FX를 지원하는 오브젝트에 제한이 있었습니다.

// v3 방식 (FX):
sprite.preFX.addGlow(0xff00ff, 4);
sprite.postFX.addBlur(0, 2, 2, 1);// v4 방식 (필터):
sprite.enableFilters();
sprite.filters.internal.addGlow(0xff00ff, 4, 0, 1);
sprite.filters.external.addBlur(0, 2, 2, 1);// v3 방식 (BitmapMask):
const mask = new Phaser.Display.Masks.BitmapMask(scene, maskImage);
sprite.setMask(mask);// v4 방식 (FilterMask):
sprite.enableFilters();
sprite.filters.internal.addMask(maskImage);

내부 필터와 외부 필터의 차이: 내부 필터는 카메라 변환 전에 실행됩니다(객체 로컬 공간, 처리 비용이 적음). 외부 필터는 그 후에 실행됩니다(스크린 공간, 전체 해상도).


RenderNodes (파이프라인 대체)

v3에서 파이프라인은 종종 여러 가지 역할을 처리하던 렌더링 시스템이었습니다. v4에서는 각 RenderNode가 run() 메서드를 통해 단일 렌더링 작업을 처리합니다. 일부 노드에는 그리기 전에 상태를 축적하는 batch() 메서드도 있습니다.

아키텍처

RenderNodeManager (WebGL 렌더러 상)는 모든 렌더 노드를 소유합니다. 게임 오브젝트는 역할 기반 매핑을 통해 노드를 참조합니다.

// 게임 오브젝트의 렌더 노드 역할:
// - 'Submitter': 각 요소에 대해 다른 노드 역할을 실행합니다.
// - 'Transformer': 버텍스 좌표를 제공합니다.
// - 'Texturer': 텍스처를 처리합니다.// 게임 오브젝트에는 기본 및 사용자 정의 렌더 노드 맵이 있습니다:
gameObject.defaultRenderNodes  // 역할별 내장 노드
gameObject.customRenderNodes   // 역할별 재정의
gameObject.renderNodeData      // 노드 이름을 키로 하는 데이터

사용자 정의 렌더 노드 설정

// 특정 렌더 역할을 재정의:
gameObject.setRenderNodeRole('Submitter', 'MyCustomSubmitter');// 렌더 노드에 데이터 전달:
gameObject.setRenderNodeRole('Transformer', 'MyTransformer', {
    customProperty: 42
});// 사용자 정의 노드 제거 (기본값으로 복원):
gameObject.setRenderNodeRole('Submitter', null);

내장 렌더 노드 유형

배치 핸들러 (드로우 콜당 여러 오브젝트를 누적하여 렌더링):

  • BatchHandlerQuad -- 표준 쿼드 배치 (Image, Sprite, BitmapText 등)
  • BatchHandlerQuadSingle -- 단일 쿼드 변형
  • BatchHandlerTileSprite -- TileSprite 배칭
  • BatchHandlerTriFlat -- 평면 삼각형 배치 (Graphics, Shape)
  • BatchHandlerPointLight -- 포인트 라이트 배치
  • BatchHandlerStrip -- 삼각형 스트립 배치

서브미터 (객체 유형별 좌표 렌더링):

  • SubmitterQuad, SubmitterTile, SubmitterTileSprite
  • SubmitterSpriteGPULayer, SubmitterTilemapGPULayer

변환기 (버텍스 위치 계산):

  • TransformerImage, TransformerStamp, TransformerTile, TransformerTileSprite

텍스처러 (텍스처 바인딩 관리):

  • TexturerImage, TexturerTileSprite

필터 (포스트 프로세싱 — filters-and-postfx.md 참조):

  • BaseFilter, BaseFilterShader
  • FilterBarrel, FilterBlend, FilterBlocky, FilterBlur (Low/Med/High 변형)
  • FilterBokeh, FilterColorMatrix, FilterCombineColorMatrix
  • FilterDisplacement, FilterGlow, FilterGradientMap, FilterImageLight
  • FilterKey, FilterMask, FilterNormalTools, FilterPanoramaBlur
  • FilterParallelFilters, FilterPixelate, FilterQuantize
  • FilterSampler, FilterShadow, FilterThreshold, FilterVignette, FilterWipe

기타:

  • Camera, FillCamera, FillRect, FillPath, FillTri
  • DrawLine, StrokePath, ShaderQuad
  • ListCompositor, RebindContext, YieldContext
  • DynamicTextureHandler

확장: 사용자 정의 RenderNodes

// 사용자 정의 노드 생성자 등록:
renderer.renderNodes.addNodeConstructor('MyNode', MyNodeClass);// 또는 미리 생성된 노드 인스턴스 추가:
renderer.renderNodes.addNode('MyNode', myNodeInstance);

새로운 게임 오브젝트

CaptureFrame

디스플레이 리스트 내 해당 위치에서 현재 프레임버퍼의 내용을 텍스처로 캡처합니다. 자체적으로는 아무것도 렌더링하지 않습니다. WebGL 전용입니다.

// 디스플레이 리스트에서 이 코드보다 위에 있는 모든 요소가 캡처됩니다:
const image1 = this.add.image(400, 300, 'background');// 카메라에서 프레임버퍼 사용을 활성화합니다:
this.cameras.main.setForceComposite(true);// 캡처 지점을 생성합니다:
const capture = this.add.captureFrame('myCapturedTexture');// 캡처된 텍스처를 다른 오브젝트에 적용:
const overlay = this.add.image(400, 300, 'myCapturedTexture');
// 오버레이에 필터를 적용하여 캡처된 장면을 왜곡

주요 사항:

  • camera.setForceComposite(true) 또는 프레임버퍼 컨텍스트(필터, DynamicTexture, 부분 알파가 적용된 카메라)가 필요합니다
  • 필터가 적용된 컨테이너 내부에서는 해당 컨테이너의 내용물만 캡처됩니다
  • visible = false로 설정하면 캡처가 중지됩니다
  • 컴포넌트: BlendMode, Depth, RenderNodes, Visible

출처: src/gameobjects/captureframe/CaptureFrame.js

그라데이션

GPU로 렌더링된 색상 그라데이션을 표시합니다. Shader를 상속받습니다. ColorBand 객체를 포함하는 구성 가능한 ColorRamp를 사용하여 선형, 방사형 및 기타 모양 모드를 지원합니다.

// 간단한 선형 그라데이션:
const grad = this.add.gradient(undefined, 100, 100, 200, 200);// 여러 색상 밴드가 포함된 복잡한 방사형 그라데이션:
const halo = this.add.gradient({
   bands: [
        { start: 0.5, end: 0.6, colorStart: [0.5, 0.5, 1, 0], colorEnd: 0xffffff, colorSpace: 1, interpolation: 4 },
        { start: 0.6, end: 1, colorStart: 0xffffff, colorEnd: [1, 0.5, 0.5, 0], colorSpace: 1, interpolation: 3 }
    ],
    dither: true,
    repeatMode: 1,
    shapeMode: 2,       // 방사형
    start: { x: 0.5, y: 0.5 },
    shape: { x: 0.5, y: 0.0 }
}, 400, 300, 800, 800);// 애니메이션:
halo.offset = 0.1 * (1 + Math.sin(time / 1000));

주요 세부 정보:

  • 구성: 밴드, shapeMode, repeatMode, start, shape, dither를 포함한 GradientQuadConfig
  • ColorBand 객체를 사용하여 ColorRamp를 통해 색상 정의 (HSV, 다양한 보간 모드 지원)
  • 실행 시 램프 데이터를 수정한 후 gradient.ramp.encode()를 호출

소스: src/gameobjects/gradient/Gradient.js

노이즈 게임 오브젝트

모든 노이즈 유형은 Shader를 상속하며 WebGL에서만 사용 가능합니다. 다음 여섯 가지 변형이 제공됩니다:

// 기본 백색 노이즈:
const noise = this.add.noise({
    noiseOffset: [0, 0],
    noisePower: 1
}, 100, 100, 256, 256);// 사용자 정의가 가능한 셀룰러 노이즈:
const cells = this.add.noiseCell2D({
    noiseOffset: [0, 0],
   noiseIterations: 3,
    noiseNormalMap: true    // 조명을 위한 노멀 맵으로 출력
}, 200, 200, 256, 256);// 자연스러운 효과를 위한 심플렉스 노이즈:
const simplex = this.add.noiseSimplex2D({
    noiseFlow: 0,           // 변화를 위해 이 값을 애니메이션화
   noiseIterations: 4,
    noiseWarpAmount: 0.5,   // 난류 효과
    noiseSeed: 42,
    noiseNormalMap: false
}, 300, 300, 256, 256);

모든 노이즈 유형에 공통적으로 적용되는 속성:

  • noiseOffset -- 패턴을 스크롤하기 위한 [x, y] 배열
  • noisePower -- 출력 레벨 조절 (값이 높을수록 높은 값을 억제)
  • noiseNormalMap -- 출력 노멀 맵 (조명 통합용)
  • noiseIterations -- 디테일 수준 (셀룰러/심플렉스 유형)

수학적 대응 함수: Phaser.Math.Hash(), Phaser.Math.HashCell(), Phaser.Math.HashSimplex()

출처: src/gameobjects/noise/

SpriteGPULayer

정적 GPU 버퍼에 데이터를 저장하여 단일 드로우 호출로 매우 많은 수의 쿼드(최대 수백만 개)를 렌더링합니다. 개별 스프라이트보다 최대 100배 빠릅니다. WebGL 전용입니다.

const layer = this.add.spriteGPULayer(texture, size); // size = 멤버의 최대 개수// 멤버 추가 (점진적으로 추가하지 말고 한 번에 모두 추가):
const member = { x: 100, y: 200, frame: 'tree', scaleX: 1, scaleY: 1, alpha: 1 };
layer.addMember(member);// 항목이 수백만 개에 달할 경우 효율성을 위해 멤버 객체를 재사용합니다:
member.x = 300;
member.y = 400;
member.frame = 'bush';
layer.addMember(member);// 레이어에 조명 적용:
layer.setLighting(true);

주요 사항:

  • 단일 텍스처만 사용 가능(멀티 아틀라스 불가), 레이어당 이미지 1개
  • 멤버는 생성 시 정의된 트윈(tween) 스타일의 애니메이션(페이드, 바운스, 웨이브, 색상 변화)을 지원합니다
  • 버퍼 내용 업데이트는 비용이 많이 듭니다 — 한 번만 채우고 변경하지 마세요
  • 픽셀 아트의 경우 이음새가 생기지 않도록 2의 제곱 크기의 텍스처를 사용하는 것이 권장됩니다
  • scaleX/scaleY/alpha를 0으로 설정하여 멤버를 시각적으로 “제거”할 수 있습니다(버퍼 재구성을 방지함)
  • 컴포넌트: Alpha, BlendMode, Depth, ElapseTimer, Lighting, Mask, RenderNodes, TextureCrop, Visible

출처: src/gameobjects/spritegpulayer/SpriteGPULayer.js


새로운 컴포넌트

전체 컴포넌트 참조: game-object-components.md

Lighting 컴포넌트

라이팅 파이프라인을 할당하던 v3 방식을 대체합니다. WebGL 전용입니다.

// v3 방식:
sprite.setPipeline('Light2D');// v4 방식:
sprite.setLighting(true);// 셀프 섀도잉 (텍스처 밝기를 기반으로 표면 그림자 시뮬레이션):
sprite.setSelfShadow(true, 0.5,1/3);
// 인자: enabled, penumbra (값이 낮을수록 더 선명함), diffuseFlatThreshold (0-1)// 자체 그림자에 게임 전체 기본값 적용:
sprite.setSelfShadow(null);  // config.render.selfShadow에서 값을 읽음

지원 대상: BitmapText, Blitter, Graphics, Shape, Image, Sprite, Particles, SpriteGPULayer, Stamp, Text, TileSprite, Video, TilemapLayer, TilemapGPULayer.

배치 관련 참고 사항: 라이팅은 셰이더를 변경하므로 배치를 깨뜨립니다. 최상의 성능을 얻으려면 조명이 적용된 오브젝트와 조명이 적용되지 않은 오브젝트를 각각 그룹화하십시오.

출처: src/gameobjects/components/Lighting.js

RenderSteps 컴포넌트

게임 오브젝트의 렌더링 프로세스에 사용자 정의 로직을 삽입할 수 있게 해줍니다. WebGL 전용입니다. 필터 시스템은 내부적으로 RenderSteps를 사용합니다.

// 사용자 정의 렌더링 단계 추가:
gameObject.addRenderStep(function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) {
    // 사용자 정의 렌더링 로직
    // 준비가 되면 다음 단계를 호출:
   var nextFn = gameObject._renderSteps[renderStep + 1];
    if (nextFn) {
        nextFn(renderer, gameObject, drawingContext, parentMatrix, renderStep + 1, displayList, displayListIndex);
    }
});

주요 사항:

  • 단계는 _renderSteps 배열에 저장되며, renderWebGLStep()을 통해 실행됩니다
  • 첫 번째 단계가 가장 먼저 실행되며, 후속 단계를 호출하는 역할을 담당합니다
  • 이것이 바로 필터가 renderWebGL 흐름을 지연시키고 제어하는 방식입니다

출처: src/gameobjects/components/RenderSteps.js

RenderNodes 컴포넌트

게임 오브젝트에 defaultRenderNodes, customRenderNodesrenderNodeData 맵을 제공합니다. 사용법은 위의 RenderNodes 섹션을 참조하십시오.

출처: src/gameobjects/components/RenderNodes.js


TilemapGPULayer

전체 타일맵 참조: tilemaps.md

고성능 GPU 기반 타일맵 렌더링. 특수 셰이더를 통해 전체 레이어를 단일 쿼드로 렌더링합니다. WebGL 전용입니다.

// gpu 플래그를 사용하여 Tilemap을 통해 생성:
const map = this.make.tilemap({ key: 'level1' });
const tileset = map.addTilesetImage('tiles', 'tilesImage');
const gpuLayer = map.createLayer('Ground', tileset, 0, 0, true);  // 마지막 인자: gpu = true

기능:

  • 단일 텍스처 이미지를 사용하는 단일 타일셋
  • 최대 4096x4096 타일, 최대 2^23개의 고유 타일 ID
  • 타일 뒤집기 및 애니메이션 지원
  • 정투영 타일맵만 지원 (등각 투영/육각형 타일맵 미지원)
  • LINEAR 모드에서 완벽한 텍스처 필터링 (타일 이음새 없음)
  • 비용은 타일 단위가 아닌 픽셀 단위로 계산되므로, 표시되는 타일이 많아도 성능 저하 없음

제한 사항:

  • 여러 타일셋을 사용할 수 없음
  • 편집 시 업데이트를 위해 generateLayerDataTexture()를 수동으로 호출해야 함
  • 정투영(Orthographic) 모드만 지원

내부 데이터: 타일 데이터는 텍스처에 저장됩니다(타일당 4바이트: 플립 비트 2개, 애니메이션 비트 1개, 미사용 비트 1개, 28비트 타일 인덱스). 애니메이션 데이터는 별도의 텍스처에 저장됩니다.

출처: src/tilemaps/TilemapGPULayer.js


자세한 구성 옵션, API 참조 표 및 소스 파일 매핑에 대해서는 참조 가이드를 참조하십시오.

GitHub에서 보기

Phaser 4 New Features

New features and capabilities in Phaser 4: Filters (replacing FX/BitmapMask), RenderNodes (replacing Pipelines), CaptureFrame, Gradient, Noise game objects, SpriteGPULayer, TilemapGPULayer, Lighting component, RenderSteps, and new tint modes.

Related skills: ../v3-to-v4-migration/SKILL.md, ../filters-and-postfx/SKILL.md, ../game-object-components/SKILL.md, ../tilemaps/SKILL.md

Migrating from v3? See the v3 to v4 Migration Guide for step-by-step code changes, removed APIs, and a migration checklist.

Overview: What Changed in v4

Phaser 4 is a complete overhaul of the WebGL rendering engine. The v3 renderer let each subsystem manage WebGL state independently, causing conflicts (e.g. certain FX breaking Masks). v4 centralizes WebGL state management through a RenderNode graph, where each node handles exactly one rendering task.

Key Removals

Key Additions

  • New GameObjects: CaptureFrame, Gradient, Noise, NoiseCell2D/3D/4D, NoiseSimplex2D/3D, SpriteGPULayer, Stamp, TilemapGPULayer
  • New Components: Lighting, RenderSteps, RenderNodes
  • New Tint Modes: MULTIPLY, FILL, ADD, SCREEN, OVERLAY, HARD_LIGHT
  • New Filters: Blend, Blocky, CombineColorMatrix, GradientMap, ImageLight, Key, Mask, NormalTools, PanoramaBlur, ParallelFilters, Quantize, Sampler, Threshold
  • GL Orientation: v4 uses standard GL orientation (Y=0 at bottom for textures)

Filters System (Replacing FX and BitmapMask)

Full reference: filters-and-postfx.md

Filters unify the v3 FX and Mask systems. Every filter takes an input image and produces an output image via a shader pass. Filters can be applied to any game object or camera -- v3 had restrictions on which objects supported FX.

// v3 approach (FX):
sprite.preFX.addGlow(0xff00ff, 4);
sprite.postFX.addBlur(0, 2, 2, 1);// v4 approach (Filters):
sprite.enableFilters();
sprite.filters.internal.addGlow(0xff00ff, 4, 0, 1);
sprite.filters.external.addBlur(0, 2, 2, 1);// v3 approach (BitmapMask):
const mask = new Phaser.Display.Masks.BitmapMask(scene, maskImage);
sprite.setMask(mask);// v4 approach (FilterMask):
sprite.enableFilters();
sprite.filters.internal.addMask(maskImage);

Internal vs External: Internal filters run before the camera transform (object-local space, cheaper). External filters run after (screen space, full-resolution).


RenderNodes (Replacing Pipelines)

In v3, a Pipeline was a rendering system that often handled multiple responsibilities. In v4, each RenderNode handles a single rendering task via its run() method. Some nodes also have a batch() method to accumulate state before drawing.

Architecture

The RenderNodeManager (on the WebGL renderer) owns all render nodes. Game objects reference nodes through role-based maps.

// RenderNode roles on a game object:
// - 'Submitter': runs other node roles for each element
// - 'Transformer': provides vertex coordinates
// - 'Texturer': handles textures// GameObjects have default and custom render node maps:
gameObject.defaultRenderNodes  // built-in nodes per role
gameObject.customRenderNodes   // overrides per role
gameObject.renderNodeData      // data keyed by node name

Setting Custom RenderNodes

// Override a specific render role:
gameObject.setRenderNodeRole('Submitter', 'MyCustomSubmitter');// Pass data to a render node:
gameObject.setRenderNodeRole('Transformer', 'MyTransformer', {
    customProperty: 42
});// Remove a custom node (falls back to default):
gameObject.setRenderNodeRole('Submitter', null);

Built-in RenderNode Types

Batch Handlers (accumulate and draw multiple objects per draw call):

  • BatchHandlerQuad -- standard quad batching (Image, Sprite, BitmapText, etc.)
  • BatchHandlerQuadSingle -- single-quad variant
  • BatchHandlerTileSprite -- TileSprite batching
  • BatchHandlerTriFlat -- flat triangle batching (Graphics, Shape)
  • BatchHandlerPointLight -- point light batching
  • BatchHandlerStrip -- triangle strip batching

Submitters (coordinate rendering per object type):

  • SubmitterQuad, SubmitterTile, SubmitterTileSprite
  • SubmitterSpriteGPULayer, SubmitterTilemapGPULayer

Transformers (compute vertex positions):

  • TransformerImage, TransformerStamp, TransformerTile, TransformerTileSprite

Texturers (manage texture binding):

  • TexturerImage, TexturerTileSprite

Filters (post-processing -- see filters-and-postfx.md):

  • BaseFilter, BaseFilterShader
  • FilterBarrel, FilterBlend, FilterBlocky, FilterBlur (Low/Med/High variants)
  • FilterBokeh, FilterColorMatrix, FilterCombineColorMatrix
  • FilterDisplacement, FilterGlow, FilterGradientMap, FilterImageLight
  • FilterKey, FilterMask, FilterNormalTools, FilterPanoramaBlur
  • FilterParallelFilters, FilterPixelate, FilterQuantize
  • FilterSampler, FilterShadow, FilterThreshold, FilterVignette, FilterWipe

Other:

  • Camera, FillCamera, FillRect, FillPath, FillTri
  • DrawLine, StrokePath, ShaderQuad
  • ListCompositor, RebindContext, YieldContext
  • DynamicTextureHandler

Extending: Custom RenderNodes

// Register a custom node constructor:
renderer.renderNodes.addNodeConstructor('MyNode', MyNodeClass);// Or add a pre-built node instance:
renderer.renderNodes.addNode('MyNode', myNodeInstance);

New Game Objects

CaptureFrame

Captures the current framebuffer contents to a texture at the point in the display list where it sits. Does not render anything itself. WebGL only.

// Everything above this in the display list gets captured:
const image1 = this.add.image(400, 300, 'background');// Enable framebuffer usage on the camera:
this.cameras.main.setForceComposite(true);// Create the capture point:
const capture = this.add.captureFrame('myCapturedTexture');// Use the captured texture on another object:
const overlay = this.add.image(400, 300, 'myCapturedTexture');
// Add filters to the overlay to distort the captured scene

Key details:

  • Requires camera.setForceComposite(true) or a framebuffer context (Filters, DynamicTexture, camera with partial alpha)
  • Inside a Container with filters, captures only that Container's contents
  • Setting visible = false stops capturing
  • Components: BlendMode, Depth, RenderNodes, Visible

Source: src/gameobjects/captureframe/CaptureFrame.js

Gradient

Displays GPU-rendered color gradients. Extends Shader. Supports linear, radial, and other shape modes with configurable ColorRamp containing ColorBand objects.

// Simple linear gradient:
const grad = this.add.gradient(undefined, 100, 100, 200, 200);// Complex radial gradient with multiple color bands:
const halo = this.add.gradient({
    bands: [
        { start: 0.5, end: 0.6, colorStart: [0.5, 0.5, 1, 0], colorEnd: 0xffffff, colorSpace: 1, interpolation: 4 },
        { start: 0.6, end: 1, colorStart: 0xffffff, colorEnd: [1, 0.5, 0.5, 0], colorSpace: 1, interpolation: 3 }
    ],
    dither: true,
    repeatMode: 1,
    shapeMode: 2,       // radial
    start: { x: 0.5, y: 0.5 },
    shape: { x: 0.5, y: 0.0 }
}, 400, 300, 800, 800);// Animate:
halo.offset = 0.1 * (1 + Math.sin(time / 1000));

Key details:

  • Config: GradientQuadConfig with bands, shapeMode, repeatMode, start, shape, dither
  • Colors defined via ColorRamp with ColorBand objects (supports HSV, various interpolation modes)
  • Call gradient.ramp.encode() after modifying ramp data at runtime

Source: src/gameobjects/gradient/Gradient.js

Noise Game Objects

All noise types extend Shader and are WebGL only. Six variants available:

// Basic white noise:
const noise = this.add.noise({
    noiseOffset: [0, 0],
    noisePower: 1
}, 100, 100, 256, 256);// Cellular noise with customization:
const cells = this.add.noiseCell2D({
    noiseOffset: [0, 0],
    noiseIterations: 3,
    noiseNormalMap: true    // output as normal map for lighting
}, 200, 200, 256, 256);// Simplex noise for natural effects:
const simplex = this.add.noiseSimplex2D({
    noiseFlow: 0,           // animate this for evolution
    noiseIterations: 4,
    noiseWarpAmount: 0.5,   // turbulence
    noiseSeed: 42,
    noiseNormalMap: false
}, 300, 300, 256, 256);

Common properties across noise types:

  • noiseOffset -- [x, y] array to scroll the pattern
  • noisePower -- sculpt output levels (higher suppresses high values)
  • noiseNormalMap -- output normal map (for lighting integration)
  • noiseIterations -- detail level (cellular/simplex types)

Math equivalents: Phaser.Math.Hash(), Phaser.Math.HashCell(), Phaser.Math.HashSimplex()

Source: src/gameobjects/noise/

SpriteGPULayer

Renders very large numbers of quads (up to millions) in a single draw call by storing data in a static GPU buffer. Up to 100x faster than individual sprites. WebGL only.

const layer = this.add.spriteGPULayer(texture, size); // size = max number of members// Add members (do this all at once, not incrementally):
const member = { x: 100, y: 200, frame: 'tree', scaleX: 1, scaleY: 1, alpha: 1 };
layer.addMember(member);// Reuse the member object for efficiency with millions of entries:
member.x = 300;
member.y = 400;
member.frame = 'bush';
layer.addMember(member);// Enable lighting on the layer:
layer.setLighting(true);

Key details:

  • Single texture only (no multi-atlas), single image per layer
  • Members support tween-like animations (fade, bounce, wave, color shift) defined at creation
  • Updating buffer contents is expensive -- populate once, leave unchanged
  • Power-of-two textures recommended for pixel art to avoid seaming
  • "Remove" members visually by setting scaleX/scaleY/alpha to 0 (avoids buffer rebuild)
  • Components: Alpha, BlendMode, Depth, ElapseTimer, Lighting, Mask, RenderNodes, TextureCrop, Visible

Source: src/gameobjects/spritegpulayer/SpriteGPULayer.js


New Components

Full component reference: game-object-components.md

Lighting Component

Replaces the v3 approach of assigning a lighting pipeline. WebGL only.

// v3 approach:
sprite.setPipeline('Light2D');// v4 approach:
sprite.setLighting(true);// Self-shadowing (simulates surface shadows from texture brightness):
sprite.setSelfShadow(true, 0.5, 1/3);
// Args: enabled, penumbra (lower = sharper), diffuseFlatThreshold (0-1)// Use game-wide default for self-shadow:
sprite.setSelfShadow(null);  // reads from config.render.selfShadow

Supported on: BitmapText, Blitter, Graphics, Shape, Image, Sprite, Particles, SpriteGPULayer, Stamp, Text, TileSprite, Video, TilemapLayer, TilemapGPULayer.

Batching note: Lighting changes the shader, which breaks batches. Group lit objects together and unlit objects together for best performance.

Source: src/gameobjects/components/Lighting.js

RenderSteps Component

Allows injecting custom logic into the render process of a game object. WebGL only. The Filters system uses RenderSteps internally.

// Add a custom render step:
gameObject.addRenderStep(function (renderer, gameObject, drawingContext, parentMatrix, renderStep, displayList, displayListIndex) {
    // Custom rendering logic here
    // Call next step when ready:
    var nextFn = gameObject._renderSteps[renderStep + 1];
    if (nextFn) {
        nextFn(renderer, gameObject, drawingContext, parentMatrix, renderStep + 1, displayList, displayListIndex);
    }
});

Key details:

  • Steps are stored in _renderSteps array, executed via renderWebGLStep()
  • First step runs first and is responsible for calling subsequent steps
  • This is how Filters defer and control the renderWebGL flow

Source: src/gameobjects/components/RenderSteps.js

RenderNodes Component

Provides defaultRenderNodes, customRenderNodes, and renderNodeData maps on game objects. See the RenderNodes section above for usage.

Source: src/gameobjects/components/RenderNodes.js


TilemapGPULayer

Full tilemap reference: tilemaps.md

High-performance GPU-based tilemap rendering. Renders the entire layer as a single quad via a specialized shader. WebGL only.

// Create via Tilemap with the gpu flag:
const map = this.make.tilemap({ key: 'level1' });
const tileset = map.addTilesetImage('tiles', 'tilesImage');
const gpuLayer = map.createLayer('Ground', tileset, 0, 0, true);  // last arg: gpu = true

Capabilities:

  • Single tileset with single texture image
  • Maximum 4096x4096 tiles, up to 2^23 unique tile IDs
  • Tile flipping and animation supported
  • Orthographic tilemaps only (no isometric/hexagonal)
  • Perfect texture filtering in LINEAR mode (no tile seams)
  • Cost is per-pixel, not per-tile -- no performance loss with many visible tiles

Restrictions:

  • Cannot use multiple tilesets
  • Editing requires manual generateLayerDataTexture() call to update
  • Orthographic only

Internal data: Tile data stored in a texture (4 bytes/tile: 2 flip bits, 1 animation bit, 1 unused, 28-bit tile index). Animation data in a separate texture.

Source: src/tilemaps/TilemapGPULayer.js


For detailed configuration options, API reference tables, and source file maps, see the reference guide.

모든 파일

0개 파일

v4-new-features 설치

스킬 파일을 다운로드하여 .claude/skills/ 디렉터리에 압축을 풀어주세요.

ZIP 다운로드

저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.

git clone https://github.com/phaserjs/phaser/tree/master/skills/v4-new-features # Copy the skill folder to .claude/skills/ or .codex/skills/

복사 복사
빠른 설정: skill 폴더를 .claude/skills/로 복사하면 Claude가 해당 스킬을 자동으로 감지하여 사용합니다.
저장소 phaserjs/phaser

관련 스킬

multica-creating-agents
업데이트 된 시간 2026년 8월 12일
tilemaps
업데이트 된 시간 2026년 8월 4일
agent-github-pr-manager
업데이트 된 시간 2026년 8월 3일
pixijs-application
업데이트 된 시간 2026년 8월 4일
OR