phaserjs/phaser/render-textures
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
Draw Game Objects, textures and fills into an off-screen texture in Phaser 4 with RenderTexture (this.add.renderTexture) and DynamicTexture (this.textures.addDynamicTexture): draw, stamp, capture, repeat, erase, fill, clear, render, preserve, callback, renderMode, saveTexture, snapshot. Use when making a paint or drawing app, trails, decals, fog of war, a minimap, a composited or procedurally generated texture, a screenshot, or reading a pixel back. Corrects v3 habits: nothing appears until render() is called, draw x/y is an offset added to the object's position, and addDynamicTexture returns null for a key in use. Triggers on: RenderTexture, DynamicTexture, draw to texture, stamp, snapshot, capture, offscreen.
Install
npx vskill@latest install phaserjs/phaser/render-texturesSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/render-textures.
Render Textures and Dynamic Textures
Drawing into textures at runtime: the DynamicTexture (a texture in the Texture Manager) and the RenderTexture (an Image that owns a DynamicTexture and proxies its drawing methods).
Source: src/textures/DynamicTexture.js, src/gameobjects/rendertexture/RenderTexture.js, src/renderer/webgl/renderNodes/DynamicTextureHandler.js, src/textures/typedefs/StampConfig.js, src/textures/typedefs/CaptureConfig.js. Related: graphics-and-shapes, cameras, masks-and-stencils, sprites-and-images.
Quick start
Which one?
- RenderTexture for one visible drawing surface (paint canvas, trail, composited sprite). It extends Image, so it has position, origin (0.5), scale, alpha, filters, input. Its DynamicTexture is
rt.texture, already in the Texture Manager under a random key.rt.saveTexture('name')renames that key so other objects can use it. - DynamicTexture when many objects or Scenes share the texture, or it is never shown directly (a mask source, a shader input, a generated spritesheet). Textures are global, so it survives Scene changes until you
this.textures.remove(key). - Both have the same drawing methods. Each has its own
camera.
The command buffer
Drawing methods (draw, stamp, capture, repeat, erase, fill, clear, callback) only queue commands. render() runs them, then empties the buffer. All of them chain.
preserve(true)keeps the buffer afterrender(), so the same commands run on every laterrender(). Queue them once; don't add more each frame or the buffer grows without limit. Start withclear()so they don't pile up on top of each other.callback(fn)queues a function that runs at that point duringrender().rt.renderMode(RenderTexture only):
| Mode | Each frame | |
|---|---|---|
'render' (default) | Draws its texture like an Image. You call render() when the contents change. | |
'redraw' | Calls render() but doesn't draw itself. It must still be visible and on the display list. Use it to refresh a texture other objects show, during the render loop. | |
'all' | Calls render(), then draws itself. |
rt.setRenderMode('all', true) also calls preserve(true). With 'redraw' or 'all' and no preserve, only the commands queued since the last frame run.
Drawing
- In 4.3 the
draw/eraseoffset works the same in Canvas as in WebGL. To draw a Game Object at an exact spot, passx - obj.x, y - obj.y, or usecapturewithxandy. - Game Objects use their own alpha, tint and blend mode. The
alphaandtintarguments ofdrawonly apply to texture keys and Frames.tintis WebGL only. - A Group, Container, Layer or display list only draws children whose
willRenderpasses. Direct entries and arrays are always drawn. - An object you only want in the texture shouldn't be on the display list:
this.make.image({ key: 'brush', add: false }). - An external Mask filter's mask object, or an internal one on a Graphics, Shape, Layer or unsized Container, is placed in world space, so it doesn't follow the draw offset. Move the mask object by the same amount before
render()and back after. See masks-and-stencils. - A DynamicTexture skips itself. Don't draw a RenderTexture into its own texture.
captureconfig:x,y,alpha,tint,angle(a non-zero angle beatsrotation),rotation,scale,scaleX,scaleY,originX,originY,blendMode,camera(render through another Camera), andtransform. Passtransform: 'world'to include the transform of the object's parent Container; leave it out, or pass'local', to use the object's own. It can also be aTransformMatrix.
The texture's camera
rt.camera (the same object as rt.texture.camera) positions Game Objects drawn with draw, capture and repeat. stamp ignores it.
Reading pixels back
Snapshots stall the GPU (readPixels). Don't take them every frame.
Patterns
A second Camera with a low zoom is often a simpler minimap: see cameras.
Size, keys and lifetime
rt.resize(width, height, forceEven = true)/dt.setSize(...)recreate the framebuffer and erase the contents.rt.setSizeonly changes the Game Object's size, not the texture.- Sizes are rounded up to even numbers unless
forceEvenisfalse, the last argument ofaddDynamicTexture,resizeanddt.setSize. Thethis.add.renderTexturefactory doesn't take it, so callrt.resize(w, h, false)for an odd size. - Destroying a RenderTexture destroys its texture, unless
saveTexturewas called. A saved texture lives on: remove it withthis.textures.remove(key)when done. - Mipmaps: framebuffers don't use them unless
render: { mipmapFilter: 'LINEAR_MIPMAP_LINEAR', mipmapRegeneration: true }(4.1). They are regenerated after everyrender(), which costs time. - WebGL context loss wipes the contents. Redraw them when the renderer is restored:
Gotchas
- `render()` is required. Without it, or
renderMode'redraw'/'all', nothing is drawn. - Order matters. Commands run in the order queued: a
fillafter adrawcovers it. - `addDynamicTexture(key)` returns `null` if the key is in use, and logs an error. On a Scene restart, reuse or remove the old texture first.
- Preserved buffers replay. With
preserve(true), queue once. Adding commands every frame leaks. - `stamp` ignores the camera; `draw`, `capture` and `repeat` use it.
- Stamp origin is 0.5; repeat origin is 0.
stampcenters on x, y;repeatfills from its top-left. - Edges in framebuffers. Since 4.3, SDF-drawn Graphics and Shapes (circles, rounded rectangles, lines, strokes) are smooth in a texture. Triangle fills such as polygons and stars have hard edges there, as framebuffers have no multisampling.
- `this.add.stamp(x, y, key)` is a Game Object, an Image that ignores camera scroll. It is not the
stamp()method.
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
- SKILL.md in the repositoryCheckingskills/render-textures/SKILL.md
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.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (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
[](https://verified-skill.com/skills/phaserjs/phaser/render-textures)