
render-textures
Use this skill when using RenderTexture or DynamicTexture in Phaser 4. Covers drawing game objects to textures, dynamic texture creation, snapshot/screenshot, stamps, and off-screen rendering. Triggers on: RenderTexture, DynamicTexture, snapshot, draw to texture, stamp.
- Installs
- 776
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/phaserjs/phaser --skill render-textures- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads render-textures automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Render Textures and Dynamic Textures
Drawing game objects to off-screen textures in Phaser 4 -- RenderTexture game object, DynamicTexture for shared textures, the Stamp helper, command-buffer rendering, snapshots, procedural generation, and minimap patterns.
Key source paths: src/gameobjects/rendertexture/, src/textures/DynamicTexture.js, src/gameobjects/stamp/, src/textures/typedefs/StampConfig.js, src/textures/typedefs/CaptureConfig.js
Related skills: ../sprites-and-images/SKILL.md, ../loading-assets/SKILL.md, ../cameras/SKILL.md
Quick Start
// In a Scene's create() method:
// 1. RenderTexture -- a visible game object with its own DynamicTexture
const rt = this.add.renderTexture(400, 300, 256, 256);
rt.draw('player', 128, 128); // draw a texture by key at center
rt.fill(0x222244, 0.5); // semi-transparent fill
rt.render(); // flush the command buffer
// 2. DynamicTexture -- a shared texture in the Texture Manager
const dt = this.textures.addDynamicTexture('composite', 512, 512);
dt.stamp('coin', null, 64, 64, { scale: 2, angle: 45 });
dt.render();
this.add.image(400, 300, 'composite'); // any game object can use it
// 3. Stamp game object -- lightweight Image that ignores camera scroll
const hud = this.add.stamp(10, 10, 'heart');
Core Concepts
RenderTexture vs DynamicTexture
Phaser 4 splits texture-drawing into two layers:
| RenderTexture | DynamicTexture | |
|---|---|---|
| What it is | Image game object + auto-created DynamicTexture | Texture in the Texture Manager |
| Created via | this.add.renderTexture(x, y, w, h) | this.textures.addDynamicTexture(key, w, h) |
| Visible on its own | Yes (it extends Image) | No (must be assigned to a game object) |
| Shared across objects | Possible via saveTexture(key) | Yes, by key |
| Cross-scene use | No (belongs to one Scene) | Yes (textures are global) |
| Has position/scale/alpha | Yes (all Image components) | No (it is a Texture, not a GameObject) |
When to use which:
- Use RenderTexture when you need a single visible surface you draw onto (paint canvas, trail effect, composite sprite).
- Use DynamicTexture when many game objects share the same generated texture, or you need a texture for masks/shaders, or you need cross-scene access.
RenderTexture is a thin proxy. Methods like draw(), stamp(), fill(), clear(), erase(), snapshot() all delegate to its underlying this.texture (a DynamicTexture).
Origin note: RenderTexture extends Image, so its origin defaults to (0.5, 0.5). If you want top-left positioning (common for full-screen or minimap RTs), call rt.setOrigin(0, 0).
The Command Buffer (v4 Architecture)
In Phaser 4, drawing calls (draw, stamp, fill, clear, erase, repeat, capture) do not execute immediately. They push commands into a commandBuffer array. You must call .render() to flush and execute the buffer.
rt.clear();
rt.fill(0x000000);
rt.draw(sprite, 128, 128);
rt.render(); // REQUIRED -- nothing appears without this
For RenderTexture game objects, the renderMode property controls automatic rendering:
| Mode | Behavior |
|---|---|
'render' (default) | Draws the texture contents to the frame each tick. You call render() manually when content changes. |
'redraw' | Calls render() automatically every frame but does NOT display itself. Useful for textures reused by other objects. |
'all' | Calls render() every frame AND draws itself to the frame. |
rt.setRenderMode('all'); // auto-render + display every frame
rt.setRenderMode('all', true); // same, plus preserve the command buffer
Preserve Mode
By default the command buffer clears after render(). Call preserve(true) to keep commands between renders, so the same drawing replays each frame:
rt.preserve(true);
rt.clear();
rt.draw(sprite);
// On every subsequent render(), clear + draw will repeat
Stamp Game Object
Stamp (this.add.stamp(x, y, texture, frame)) is a lightweight Image subclass that ignores camera scroll and transform during rendering. It is used internally by DynamicTexture for drawing operations and is also useful for HUD elements. It extends Image with custom render nodes (DefaultStampNodes).
The stamp() Method vs the Stamp Game Object
These are different things:
rt.stamp(key, frame, x, y, config)-- a method on RenderTexture/DynamicTexture that draws a texture frame to the surface with transform options (alpha, tint, angle, scale, origin, blendMode).this.add.stamp(x, y, texture, frame)-- a factory that creates a Stamp game object added to the Scene display list.
Common Patterns
Drawing Sprites and Game Objects
const rt = this.add.renderTexture(0, 0, 800, 600);
// Single game object at an offset
rt.draw(sprite, 100, 100);
// Array of objects
rt.draw([sprite1, sprite2, sprite3]);
// Group or Container (only visible children are drawn)
rt.draw(enemyGroup);
rt.draw(myContainer, 50, 50); // offset added to children positions
// Entire Scene display list
rt.draw(this.children);
// Texture by string key
rt.draw('explosion', 200, 200);
// Don't forget to flush
rt.render();
The draw() method accepts: renderable game objects, Groups, Containers, Display Lists, other RenderTextures/DynamicTextures, Texture Frames, texture key strings, or arrays of any of these.
Note: alpha and tint parameters on draw() only apply to Texture Frames/strings. Game objects use their own alpha and tint when drawn.
Stamping Textures with Config
The stamp() method draws a texture frame with full transform control. The frame is centered on the x/y position by default (origin 0.5).
rt.stamp('bullet', null, 100, 100, {
alpha: 0.8,
tint: 0xff0000,
angle: 45, // degrees (takes precedence over rotation)
scale: 2, // uniform scale
scaleX: 1.5, // overrides scale for X
scaleY: 0.5, // overrides scale for Y
originX: 0, // top-left origin
originY: 0,
blendMode: 0
});
rt.render();
Capture -- Drawing with Overrides (v4)
The capture() method draws a game object with temporary property overrides, restoring originals afterward:
rt.capture(player, {
x: 64,
y: 64,
scale: 0.5,
alpha: 0.8,
rotation: Math.PI / 4,
transform: 'world', // 'local', 'world', or a TransformMatrix
camera: someCamera // optional camera override
});
rt.render();
This is useful for drawing an object at a different position/scale without modifying the object itself.
Filling and Clearing
// Fill entire texture with color
rt.fill(0xff0000); // solid red
rt.fill(0x000000, 0.5); // semi-transparent black
// Fill a region
rt.fill(0x00ff00, 1, 10, 10, 100, 50); // green rect at (10,10) size 100x50
// Clear everything (transparent)
rt.clear();
// Clear a region
rt.clear(10, 10, 100, 50);
rt.render();
Erasing
Erase uses ERASE blend mode to cut holes in the texture:
rt.fill(0xffffff); // white background
rt.erase(circleSprite, 100, 100); // punch a hole shaped like the sprite
rt.render();
Repeating / Tiling a Texture
// Fill the entire RenderTexture with a tiled pattern
rt.repeat('grass', null); // tile the whole surface
rt.repeat('brick', null, 0, 0, 256, 128); // tile a specific region
rt.repeat('tile', 'frame2', 0, 0, 512, 512, {
tileScaleX: 2,
tileScaleY: 2,
tilePositionX: 16,
alpha: 0.8
});
rt.render();
Snapshots (Pixel Capture)
Snapshots read pixel data from the framebuffer. They are expensive and blocking -- use sparingly.
// Full texture snapshot -- callback receives an HTMLImageElement
rt.snapshot(function (image) {
document.body.appendChild(image); // or use as texture source
});
// Area snapshot
rt.snapshotArea(0, 0, 128, 128, function (image) {
// image is 128x128 region from top-left
}, 'image/jpeg', 0.8);
// Single pixel -- callback receives a Phaser.Display.Color
rt.snapshotPixel(64, 64, function (color) {
console.log(color.r, color.g, color.b, color.a);
});
Using as a Texture Source for Other Objects
const rt = this.add.renderTexture(0, 0, 256, 256);
rt.draw(complexScene);
rt.render();
// Register in the Texture Manager under a key
rt.saveTexture('composited');
// Now any game object can use it
this.add.image(400, 300, 'composited');
this.add.sprite(100, 100, 'composited');
// Updates to the RenderTexture automatically reflect on all users
For DynamicTexture, the key is set at creation time:
const dt = this.textures.addDynamicTexture('terrain', 1024, 1024);
dt.repeat('grass', null);
dt.render();
this.add.image(512, 512, 'terrain'); // already keyed
Procedural Generation
const dt = this.textures.addDynamicTexture('starfield', 800, 600);
dt.fill(0x000011);
for (let i = 0; i < 200; i++) {
const x = Phaser.Math.Between(0, 800);
const y = Phaser.Math.Between(0, 600);
const brightness = Phaser.Math.FloatBetween(0.3, 1);
dt.stamp('star', null, x, y, { alpha: brightness, scale: Phaser.Math.FloatBetween(0.5, 1.5) });
}
dt.render();
this.add.image(400, 300, 'starfield');
Minimap Pattern
create() {
// Small RenderTexture as minimap
this.minimap = this.add.renderTexture(700, 50, 150, 100);
this.minimap.setScrollFactor(0); // fixed to camera
this.minimap.setRenderMode('all'); // auto-render every frame
this.minimap.preserve(true);
}
// In update or a callback:
this.minimap.clear();
this.minimap.fill(0x111111);
// Draw scaled-down versions of world objects
this.minimap.capture(player, { x: px * 0.1, y: py * 0.1, scale: 0.1 });
// render() is automatic in 'all' mode
Callbacks in the Command Buffer
Insert logic between draw commands that executes during render():
rt.clear();
rt.draw(background);
rt.callback(() => {
// Runs during render, after background is drawn
sprite.setTint(0xff0000);
});
rt.draw(sprite);
rt.callback(() => {
sprite.setTint(0xffffff); // restore after drawing
});
rt.render();
Resizing
// Resize erases all content and recreates the framebuffer
rt.resize(512, 512);
// Optional: disable force-even rounding
rt.resize(513, 513, false);
Internal Camera
Both RenderTexture and DynamicTexture have a .camera property that controls how game objects are positioned when drawn. Scroll, zoom, and rotate this camera to transform drawn content. Note: stamp() ignores the camera; only draw() and game object rendering respect it.
rt.camera.setScroll(100, 50);
rt.camera.setZoom(2);
rt.draw(sprite); // sprite drawn with camera transform applied
rt.render();
API Quick Reference
RenderTexture (extends Image)
| Method | Signature | Description |
|---|---|---|
draw | (entries, x?, y?, alpha?, tint?) | Draw game objects, textures, groups, etc. |
capture | (entry, config) | Draw with temporary property overrides |
stamp | (key, frame?, x?, y?, config?) | Stamp a texture frame with transform |
erase | (entries, x?, y?) | Draw using ERASE blend mode |
fill | (rgb, alpha?, x?, y?, w?, h?) | Fill with color |
clear | (x?, y?, w?, h?) | Clear to transparent |
repeat | (key, frame?, x?, y?, w?, h?, config?) | Tile a texture as fill pattern |
render | () | Flush the command buffer |
preserve | (bool) | Keep command buffer between renders |
callback | (fn) | Insert callback into command buffer |
resize | (w, h?, forceEven?) | Resize (erases content) |
saveTexture | (key) | Register in Texture Manager |
setRenderMode | (mode, preserve?) | Set 'render', 'redraw', or 'all' |
snapshot | (callback, type?, quality?) | Full snapshot to Image |
snapshotArea | (x, y, w, h, callback, type?, quality?) | Area snapshot |
snapshotPixel | (x, y, callback) | Single pixel to Color |
DynamicTexture (extends Texture)
Same drawing methods as RenderTexture (draw, stamp, erase, fill, clear, repeat, capture, render, preserve, callback, snapshot, snapshotArea, snapshotPixel), plus:
| Method/Property | Description |
|---|---|
setSize(w, h?, forceEven?) | Resize the texture |
camera | Internal Camera for draw positioning |
commandBuffer | Array of pending draw commands |
drawingContext | WebGL DrawingContext with framebuffer |
getWebGLTexture() | Returns the underlying WebGLTextureWrapper |
StampConfig (for stamp() config parameter)
| Property | Default | Description |
|---|---|---|
alpha | 1 | Alpha value |
tint | 0xffffff | Tint color (WebGL only) |
angle | 0 | Degrees (overrides rotation if non-zero) |
rotation | 0 | Radians |
scale | 1 | Uniform scale |
scaleX / scaleY | 1 | Per-axis scale (overrides scale) |
originX / originY | 0.5 | Origin point |
blendMode | 0 | Blend mode |
CaptureConfig (for capture() config parameter)
| Property | Description |
|---|---|
transform | 'local', 'world', or a TransformMatrix |
camera | Camera override for rendering |
x, y, alpha, tint, angle, rotation | Override game object properties temporarily |
scale, scaleX, scaleY | Scale overrides |
originX, originY, blendMode | Additional overrides |
Factory Methods
this.add.renderTexture(x, y, width?, height?) // default 32x32
this.add.stamp(x, y, texture, frame?)
this.textures.addDynamicTexture(key, width?, height?, forceEven?) // default 256x256
Gotchas
-
Must call
render(). In Phaser 4, drawing methods buffer commands. Nothing appears untilrender()is called (unless usingrenderMode: 'all'or'redraw'). -
Cannot draw to itself. A DynamicTexture/RenderTexture silently skips entries that reference itself.
-
Command buffer clears after render. Call
preserve(true)before drawing if you need the same commands to replay each frame. -
stamp()ignores the internal camera. Only game objects drawn viadraw()orcapture()respect the.cameraproperty. Texture stamps are positioned absolutely. -
Default sizes differ. RenderTexture defaults to 32x32. DynamicTexture defaults to 256x256.
-
forceEvenrounds dimensions up. By default, width/height are rounded to even numbers for rendering quality. Passfalseas the last argument if you need exact odd dimensions. -
Snapshots are expensive. They use
readPixels(WebGL) which blocks the GPU pipeline. Avoid per-frame snapshots.snapshotPixelis cheaper than fullsnapshot. -
WebGL1 has no anti-aliasing on framebuffers. Shapes and Graphics drawn to a RenderTexture may have jagged edges. Use pre-rendered sprite textures instead.
-
resize()erases content. Resizing destroys and recreates the framebuffer. -
saveTexturerenames, does not copy. CallingsaveTexture(key)assigns the DynamicTexture to the Texture Manager under that key. Calling it again with a different key renames it. Destroying the RenderTexture without saving first destroys the texture. -
draw()alpha/tint params only affect Texture Frames. When drawing game objects, they use their own alpha and tint values. Thealphaandtintparameters ondraw()only apply when drawing texture strings or Frame instances. -
WebGL context loss. DynamicTexture contents are lost on context loss. Listen for the
restorewebglevent to redraw. -
Groups/Containers: x, y offset is additive. When drawing a Group or Container with
rt.draw(group, x, y), the x/y offset is added to each child's position. Children at (100, 50) drawn with offset (10, 10) appear at (110, 60) in the texture.
Source File Map
| File | Description |
|---|---|
src/gameobjects/rendertexture/RenderTexture.js | RenderTexture game object (extends Image, proxies to DynamicTexture) |
src/gameobjects/rendertexture/RenderTextureFactory.js | this.add.renderTexture() factory registration |
src/gameobjects/rendertexture/RenderTextureRender.js | WebGL/Canvas render functions for RenderTexture |
src/gameobjects/rendertexture/RenderTextureRenderModes.js | Enum: RENDER, REDRAW, ALL |
src/textures/DynamicTexture.js | Core DynamicTexture class (command buffer, drawing, snapshots) |
src/textures/DynamicTextureCommands.js | Command constants (CLEAR, FILL, STAMP, DRAW, ERASE, etc.) |
src/textures/typedefs/StampConfig.js | StampConfig typedef for stamp() |
src/textures/typedefs/CaptureConfig.js | CaptureConfig typedef for capture() |
src/gameobjects/stamp/Stamp.js | Stamp game object (light Image, ignores camera scroll) |
src/gameobjects/stamp/StampFactory.js | this.add.stamp() factory registration |
FAQ
What does the render-textures skill do?
Use this skill when using RenderTexture or DynamicTexture in Phaser 4. Covers drawing game objects to textures, dynamic texture creation, snapshot/screenshot, stamps, and off-screen rendering. Triggers on: RenderTexture, DynamicTexture, snapshot, draw to texture, stamp.
How do I install render-textures?
Run npx skills add https://github.com/phaserjs/phaser --skill render-textures in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/render-textures/ (personal) or .claude/skills/render-textures/ (project).
Which AI agents can use render-textures?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is render-textures safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains render-textures?
It is published by phaserjs in phaserjs/phaser. It has 776 recorded installs.
More from phaserjs/phaser
game-setup-and-config
phaserjs/phaser
Use this skill when creating a new Phaser 4 game instance or configuring GameConfig options. Covers renderer selection, canvas setup, scaling, pixel art, FPS settings, boot sequence, and all config sub-objects. Triggers on: new Phaser.Game, GameConfig, game setup, renderer, pixel art, FPS.
sprites-and-images
phaserjs/phaser
Use this skill when creating Sprites or Images in Phaser 4. Covers factory methods, texture/frame selection, position, scale, rotation, tint, flip, alpha, origin, depth, and the component mixin system. Triggers on: Sprite, Image, this.add.sprite, this.add.image, texture, setTint, setAlpha.
animations
phaserjs/phaser
Use this skill when creating or controlling sprite animations in Phaser 4. Covers spritesheets, atlases, AnimationManager, AnimationState, play/stop/chain, frame callbacks, and animation events. Triggers on: sprite animation, spritesheet, play animation, animation frames.
tilemaps
phaserjs/phaser
Use this skill when working with tilemaps in Phaser 4. Covers loading Tiled JSON maps, creating tilemap layers, tile collision, dynamic tiles, tile properties, and tilemap camera culling. Triggers on: Tilemap, Tiled, tilemap layer, tile collision, tile properties.
v4-new-features
phaserjs/phaser
Use this skill when learning about new features, game objects, components, and rendering capabilities added in Phaser 4. Covers Filters, RenderNodes, CaptureFrame, Gradient, Noise, SpriteGPULayer, TilemapGPULayer, Lighting component, RenderSteps, and new tint modes. Triggers on: new in v4, Phaser 4 features, RenderNode, SpriteGPULayer, CaptureFrame, Gradient game object, Noise game object, new tint modes. For migrating v3 code to v4, see the v3-to-v4-migration skill instead.
scenes
phaserjs/phaser
Use this skill when working with Phaser 4 scenes. Covers scene lifecycle methods, scene transitions, parallel scenes, scene communication, sleeping, pausing, restarting, and the SceneManager. Triggers on: Scene, scene lifecycle, preload, create, update, scene transition, SceneManager.
Popular media & creative skills
hyperframes
heygen-com/hyperframes
Read first to make, edit, animate or render any video with HyperFrames (HTML rendered to video), including launch films, explainers, music videos, charts, maps, vertical clips, title cards, captions and overlays. Holds the render contract, the work loop and what each kind of video needs.
media-use
heygen-com/hyperframes
Get or make any media for a HyperFrames video - music, sound effects, images, icons, logos, voiceover, avatar and generated video, transcripts, cutouts, colour grades and looks - with HeyGen or free local tools, and mix placed audio. Also for footage that looks dark, flat or dull, or should be stylized or hidden.
hyperframes-registry
heygen-com/hyperframes
About 450 ready-made HyperFrames blocks and components installed as editable source - transitions, overlays, titles, kinetic type, captions, charts, map overlays, 3D, camera moves. Use it before hand-building any named visual (CRT scanlines, glitch, film grain, a chart); also for hyperframes add and catalog.
hyperframes-creative
heygen-com/hyperframes
Non-animation creative direction for HyperFrames videos. Use for design spec (frame.md / design.md) handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns, and brand / style decisions. For atomic motion patterns and scene blueprints, use hyperframes-animation.
ai-video-generation
101-skills/superpowers
Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0, HappyHorse 1.0, Wan 2.5, Grok Imagine Video, OmniHuman, Fabric, HunyuanVideo. Capabilities: text-to-video, image-to-video, reference-to-video, video editing, lipsync, avatar animation, video upscaling, foley sound. Use for: social media videos, marketing content, explainer videos, product demos, AI avatars. Triggers: video generation, ai video, text to video, image to video, veo, animate image, video from image, ai animation, video generator, generate video, t2v, i2v, ai video maker, create video with ai, runway alternative, pika alternative, sora alternative, kling alternative, seedance, happyhorse
ai-image-generation
101-skills/superpowers
Generate AI images with GPT-Image-2, FLUX, Gemini, Grok, Seedream, Reve and 50+ models via inference.sh CLI. Models: GPT-Image-2, FLUX Dev LoRA, FLUX.2 Klein LoRA, Gemini 3 Pro Image, Grok Imagine, Seedream 4.5, Reve, ImagineArt. Capabilities: text-to-image, image-to-image, inpainting, LoRA, image editing, upscaling, text rendering. Use for: AI art, product mockups, concept art, social media graphics, marketing visuals, illustrations. Triggers: flux, image generation, ai image, text to image, stable diffusion, generate image, ai art, midjourney alternative, dall-e alternative, text2img, t2i, image generator, ai picture, create image with ai, generative ai, ai illustration, grok image, gemini image, gpt image, openai image, chatgpt image