# How to make AI game VFX for three.js

> Make AI game VFX for three.js: film each spell element on black with Seedance 2.5, pack it into a 64-frame flipbook, build the spell in code. Prompts inside.

Built by @rehan_shei.
Published 2026-11-21 on https://patch.gg/blog/ai-game-vfx-threejs

You can make AI game VFX for a three.js game by filming each piece of a spell alone on a black background with an AI video model, packing every clip into a 64-frame flipbook texture, and writing the spell itself as code that layers those flipbooks with sparks, trails, decals, light and camera shake. With Seedance 2.5 on fal, an element clip costs about $1.90 and a whole new spell about $6 to 9. Each clip takes 3 to 6 minutes to film.

@rehan_shei built this method into game-vfx, an open-source skill for Claude Code that ships six finished spells (fireball, chain lightning, meteor, inferno, frost and an arcane vortex), 12 flipbooks and the runtime that draws them. You can cast all six in the browser on [game-vfx's Patch page](https://patch.gg/rehan/game-vfx). The method follows @CanItCode's Seedance-to-Niagara workflow for Unreal Engine, rebuilt for three.js.

This article covers the six steps with game-vfx's real prompts and the tuning numbers from its craft notes, and takes one spell through every step as if you were making it from scratch: the frost nova that game-vfx ships as `frost.js`, plus one element its library lacks, an ice shatter. The prompt boxes are ours, written from the skill's files; we haven't run them end to end. You should know your way around a three.js scene. You don't need to write the effects code yourself: the prompts below hand that to your coding agent.

## What you need

- A three.js game, or the skill's minimal example. The skill targets three.js 0.17x to 0.18x on WebGL2 and was tested on 0.185.
- A coding agent. game-vfx is written as a Claude Code skill; other agents can read its `SKILL.md`.
- Python 3.9 or later with numpy and Pillow, ffmpeg, and cwebp, for the flipbook maker. Node 18 or later if you want to record clips.
- A fal.ai key (`FAL_KEY`) for new clips from Seedance 2.5 by ByteDance. The six bundled spells and 12 flipbooks work without one.
- Patch's CLI, `pch`, if you want to find scenes and characters in Patch's toolbox and publish your game on Patch.

| Item                                           | Cost on Seedance 2.5 (fal, 720p) |
| ---------------------------------------------- | -------------------------------- |
| Video, per second                              | about $0.47                      |
| One element clip (4 s, square)                 | about $1.90                      |
| One pattern video (5 to 6 s, 16:9)             | about $2.40 to 2.80              |
| A new spell with 2 or 3 elements and a pattern | about $6 to 9                    |
| Sound effects (ElevenLabs on fal)              | fractions of a cent each         |

![Four boxes in a row: a text prompt, a Seedance 2.5 clip on black, an 8 by 8 flipbook and the three.js spell, each lighting up in turn](https://cdn.patch.gg/media/sha256/1f/1f/1f1f5a2c1da697918e9b500e30039b2007e73e5efbe4ddacbb58dddd998c04a8#clip "How one element travels: prompt, clip on black, 64-frame flipbook, then the spell in code.")

![A meteor, chain lightning and a frost nova's wall of ice spikes cast one after another in game-vfx's dusk arena](https://cdn.patch.gg/media/sha256/be/09/be09baf8387c9e169b6640088e1c0b0a465a55b2e4480f04a76c5d9220a36d41#clip "Meteor, chain lightning and the frost nova in game-vfx's demo arena, from @rehan_shei's video on X.")

## 1. Plan the spell as a timeline

Write the spell down as five beats: charge, release, travel, impact and aftermath. Then list its elements, and mark each one as a picture or as code.

Pictures are the things AI video is good at and code is bad at: rolling fire, smoke, a crackling orb, a burst, a vortex. Code is everything with a precise shape or path: sparks, ribbons behind a projectile, lightning between two moving points, rings, rune circles, scorch marks, light and shake. The fireball in game-vfx shows the split. Its picture elements are the flying core, the impact burst, smoke and small fires left on the ground. Its code elements are 26 glowing dots gathering in the hand, two trails, a light that rides with the ball, 70 sparks, 40 embers, a shockwave ring and a scorch mark that cools.

Before you film anything, look at what's already there. The skill's library has 12 flipbooks (fire burst, fireball core, smoke, plasma orb, lightning burst, big explosion, ground fire, fire pillar and its loop, frost burst from above, arcane burst and vortex), and its six spells are written to be copied and changed.

Ask your agent to install the game-vfx skill (clone `https://git.patch.gg/rehan/game-vfx.git` and link its `skills/game-vfx` folder into `~/.claude/skills/game-vfx`, or point another agent at `SKILL.md`) and plan your spell the way the skill says. For a frost nova that goes off when your boss slams the ground, ask which of the 12 flipbooks and which spells in `runtime/spells/` it would reuse, which new clips it would need, and what those would cost before it spends anything.

You should get back a five-beat list with every element marked flipbook or code, the library pieces to reuse, and a price for any new clips.

## 2. Film a pattern video of the spell in your scene

Take a screenshot of your game with the caster and the target in place, and have Seedance 2.5 image-to-video (`bytedance/seedance-2.5/us/image-to-video` on fal) film the whole spell in that scene.

This step is optional, but the skill recommends it for anything new. The pattern shows what the spell should look like in your own scene and how long each part lasts. It is a reference you compare against later, never something you ship.

Write the prompt the way you'd brief an artist, with sizes, colors, speed and what the spell leaves behind. game-vfx's fireball pattern (5 seconds) asks for "a small, intensely bright ball of fire, white-hot in the centre and orange at its edges, about the size of a head", which "flies fast and low straight across the stone floor, reaching the grey figure in less than half a second", and adds that "the ball casts a warm orange pool of light that slides along the paving under it." It ends: "The fire is gone within a second. A clean, punchy, readable game effect like a Diablo IV sorcerer's fireball, not a big explosion."

Every pattern ends with the same line: "Static camera, no cuts, no text. The scene, the figures and the lighting stay exactly as in the image." The skill's six patterns are 5 seconds for the fireball and chain lightning and 6 seconds for the rest.

Make a contact sheet of the result at 2 frames a second and write down when each part happens. That list is your timing for step 5.

![The meteor's pattern video next to the finished spell: on the left a Seedance shot of a fire column and flying rocks, on the right the same moment in three.js](https://cdn.patch.gg/media/sha256/9e/14/9e1448038191b8f3c7f63112541410820dbb979bd770dcb3de4e057c8a84c33c "The meteor's pattern (left, AI video) and the spell in three.js (right), from @rehan_shei's video on X.")

Ask your agent to take the screenshot and, with `FAL_KEY` set, film the frost nova's pattern through the skill's fal script: duration 5, 720p, the screenshot as the image, a prompt briefed like an artist that ends with the skill's line, and the cost before it spends anything. Then have it make the contact sheet and list when each part happens.

## 3. Film each element alone on pure black

Film every picture element as its own clip with Seedance 2.5 text-to-video (`bytedance/seedance-2.5/us/text-to-video`): 4 seconds, 720p, aspect 1:1, bitrate_mode high, one element in the middle of a black frame. Keep generate_audio on: Seedance's own sound costs nothing more and is raw material for whooshes and booms.

Black is what makes the clip usable. A flipbook is drawn on a flat card in the game, and every pixel that isn't the effect has to vanish. On a pure black background, the black becomes transparent in step 4. Every element prompt in game-vfx ends with the same rules:

> Static locked-off camera. Pure black background (#000000) the whole time. No ground, no environment, no people, no text, no logo. Game VFX element filmed for a flipbook.

The full fire burst prompt that made the library's fire burst reads: "A single compact fireball explosion in empty black space. The clip opens on pure black; a white-hot flash appears at the exact centre and bursts outward into a ball of rolling orange and yellow flames with curling tongues of fire, which grows to fill about two thirds of the frame, then breaks apart into glowing embers and fades completely back to black. Front view, perfectly centred, never touching the frame edges, no smoke. Slow motion, highly detailed realistic fire."

The rules that make a clip work, from the skill:
- **One element, centered, never touching the frame edges.** Say so in the prompt.
- **Say the view.** "Front view" for bursts, "seen from directly above, looking straight down" for anything that lies on the ground (novas, vortices, scorch), "side view, rising from the bottom centre" for eruptions and pillars.
- **Say the whole life.** A burst needs a start on black and an end on black. A loop needs to stay "the same size the whole time, never moving, growing or fading".
- **Ask for slow motion on bursts.** You get more frames of the interesting part, and the flipbook plays it back fast.
- **Film smoke, dust and mist white on black.** The shader tints it later, so one smoke clip serves every color.

Run several clips at once (each takes 3 to 6 minutes) and look at a contact sheet of each before you use it.

![A Seedance clip of a fire explosion on pure black next to the 8 by 8 flipbook made from it](https://cdn.patch.gg/media/sha256/85/f1/85f1d9f49142c0824a72d1ac16830f87697d0763c2e5a1439827bad594536886 "An element clip on black (left) and its 64-frame flipbook (right), from @rehan_shei's video on X.")

For the frost nova, the library already has frost-burst, seen from above, so ask your agent for the one element it lacks: the ice shattering into a burst of glittering blue-white shards, front view, centered, opening and ending on pure black, in slow motion, filmed through the skill's fal script with the settings and black-background rules above. Have it tell you the cost first and show you a contact sheet of the clip.

## 4. Turn each clip into a 64-frame flipbook

Run each clip through the skill's flipbook maker, which packs it into one 2048 px texture of 8 by 8 frames, 256 px each.

The script does five things. It keeps only the seconds where the effect is alive (where its brightness is above 2% of its peak). It crops to a square around everything the effect touches. It lifts black to transparency: in its additive mode the alpha is the brightest channel, and in its smoke mode the color is white and the alpha is the brightness. It fades the edges so no card ever shows a hard square. And for loops, it takes the steady middle of the clip (15 to 95%) and crossfades the last quarter of the frames into the first.

For the library's fire burst, it kept 0.458 to 3.458 seconds of a 24 fps clip and cropped a 960 by 960 square.

![The fire burst flipbook: 64 frames in an 8 by 8 grid, a white flash growing into a ball of orange fire that breaks up and fades to black](https://cdn.patch.gg/media/sha256/6b/a8/6ba896a5b43ac819b298de87f65f10718dea256b7db2ec4dd9aa4399cff0ac96 "The library's fire burst as a flipbook, shown on black. Read it left to right, top to bottom.")

Two options fix the common problems. A band element, such as a line of flames, shows hard edges at the sides when cropped square: crop it with `--crop` and taper it with `--mask flame`. A clip with a bad tail gets `--end`. Ship the flipbooks as WebP at quality 92.

Ask your agent to turn your ice shatter clip into a flipbook with the skill's `make_flipbook.py`, show you its contact sheet, trim a bad tail with `--end` if there is one, then convert it with `cwebp -q 92` and put it next to the library's flipbooks.

## 5. Write the spell in code on the runtime

Write the spell as one function that schedules its layers on a timeline, using the skill's runtime, and time it against your pattern.

The runtime gives you the pieces. A system draws a flipbook in one of four modes: billboard (facing the camera), stretch (for sparks), ground (flat on the floor, for novas and vortices) and axis (upright, for flames and pillars). Code covers the rest: trails, lightning, shockwave rings, decals, rune circles, ice spikes, debris, lights and shake. Each system is one instanced draw call.

The fireball is the template, in 119 lines. The ball flies at 15 m/s with a 0.42 m trail that lives 0.075 s, plus a thin 0.07 m streak. A light of intensity 45 and range 8 rides with it. On impact: a 0.9 m flash dot, two layers of the fire burst at 2.3 m and 1.5 m, 70 sparks, 40 embers, 7 smoke puffs, a shockwave from 0.3 to 2.6 m, a scorch decal that lasts 7 seconds, and 3 small ground fires with a flickering light.

![A fireball impact in the arena: a ball of orange fire around a mannequin, sparks flying and a glowing scorch mark on the stone](https://cdn.patch.gg/media/sha256/14/37/143725a8367104be5332a889fc57d1f6e82f55345d1899c351f4da1e5dc380ef "The fireball's impact: two flipbook layers, sparks and embers in code, and the scorch decal starting to cool.")

To add it to your own game, copy the skill's `runtime/` folder in and create the effects world with `createVfx`, giving it your renderer, scene, camera and flipbook folder. Each frame, place the camera, then call `vfx.update(dt)` and `vfx.render()` in place of `renderer.render`. The runtime does its own HDR rendering with ACES tone mapping and bloom, so your renderer must output linear sRGB with tone mapping off. If you use Patch's mannequin as the caster, its one-handed push (`cast2`) releases at about 0.36 to 0.4 seconds and its crouch and slam (`cast3`) at about 0.4 seconds; time the spell to that. Any other mesh works as a caster or target through the runtime's PointActor, so you can [rig and animate a 3D character with AI](/blog/rig-animate-3d-character-ai) and cast from it.

```prompt
Add the frost nova to my three.js game with the game-vfx skill (git clone https://git.patch.gg/rehan/game-vfx.git), copying runtime/spells/frost.js as the start. Copy the skill's runtime/ folder into the game, set the renderer to linear sRGB output with no tone mapping, create the world with createVfx, and in the loop place the camera, then call vfx.update(dt) and vfx.render() instead of renderer.render; wrap the boss and the player as PointActors, and cast the nova on the boss's slam. Keep frost.js's numbers: the frost-burst flipbook in ground mode, a line shockwave to 1.8 m, a ring of 26 spikes around the target, a 10 m frost decal, 28 mist puffs in [0.62, 0.78, 0.95]. Add my ice shatter flipbook when the spikes break. Time every layer to the list from my pattern's contact sheet. If my game is on Patch, run pch check and show me the screenshots.

If pch (Patch's CLI) isn't installed, install it with curl -fsSL https://patch.gg/install.sh | sh (on Windows, in PowerShell: irm https://patch.gg/install.ps1 | iex), then run pch login and pch guide.
```

## 6. Check it against the pattern

Record the spell and put it side by side with the pattern video, then fix what doesn't match.

The skill's recorder steps the page at a fixed 60 fps in headless Chrome. For that, your page exposes `window.__app` with `step(dt)`, `fx` and `renderer`, sets `document.body.dataset.ready`, creates the renderer with `preserveDrawingBuffer` when the URL has `?capture`, and is served from a static build, not the dev server. Stepping frames means a clip plays smoothly even when the machine renders slower: the skill's notes measured about 13 to 15 fps at 1080p with 2x supersampling on an RTX 4090. It also writes the time of every sound cue next to the video; place each sound at its cue time minus the sound's attack so the hit lands on the frame. Make a contact sheet of both clips. The skill's rule: "Match the pattern's timing and what it leaves behind, not its exact look."

Every number in game-vfx's craft notes came from a side-by-side with the pattern. Here's what each pattern added for @rehan_shei:

| Spell           | First version                   | After the pattern                                                                                                   |
| --------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Fireball        | burst, sparks, ring             | fire left burning at the feet, a smoke column, a light pool under the ball                                          |
| Chain lightning | bolts held 0.5 s                | bolts held about 1 s, a second cast, crackles crawling over the floor for 1.3 s around each target                  |
| Meteor          | 26 rocks, circle gone at impact | 44 rocks thrown at 6 to 15 m/s, the rune circle lingering 2.6 s, a 7.5 m crater, a 16 m light pillar for 0.35 s     |
| Inferno         | smooth pale ribbons             | ribbons broken into flame tongues, redder, a ring of 16 upright ground-fire flipbooks, a rising pillar and its loop |
| Frost           | 15 spikes, 6 m of frost         | a ring of 26 spikes around the target, a 10 m frost decal, 28 mist puffs rolling out                                |
| Arcane          | a pink glow on the floor        | a dark void disc under the vortex, a violet outer swirl, the light cut from 70 to 24                                |

Ask your agent to set your page up for the skill's `record.mjs` the way `reference/RECORDING.md` says, record the frost nova at 60 fps from the game camera for as long as your pattern video, and put the two side by side with ffmpeg hstack. Then have it fix every place where the timing or what the spell leaves behind differs from the pattern, and record again until they match.

![Chain lightning jumping from a mannequin's hand across the arena to three blue-lit training dummies](https://cdn.patch.gg/media/sha256/0e/b4/0eb4ebbe00bb0d079c098174fc72a4c55551bb56235bbe822c05031dfe6f61df "Chain lightning after the pattern: bolts held about a second, with sparks and scorch at each target.")

## What went wrong

The numbers that fixed game-vfx's spells are in its craft notes. These are the mistakes they record:
- **Everything turned white.** ACES turns any color much above 3 on a channel into white. The first fireball impact was a 2.6 m flash dot at [20, 16, 11], a whiteout. A 0.9 m dot at [7, 5.5, 4] for 0.08 s reads as a flash. Fire flipbooks are now drawn at about [2.2, 1.5, 1.0], warm rather than white, and bloom stays at threshold 1.25, knee 0.7 and strength 0.05: "Stronger turned every hit into a white ball."
- **The burst looked like a bomb.** At 3.4 m it did. Impact bursts now run 2.2 to 2.6 m with a life of 0.6 to 0.75 s.
- **The fireball looked like a beam.** With a trail of 0.16 s and 0.55 m it did. The fix was 0.075 s and 0.42 m, plus a thin streak.
- **The target's body cut the burst in half.** Draw impact sprites 0.5 to 0.8 m toward the camera from the hit point.
- **AI bursts open on white frames.** Start them at frame 3 or 4 and ease them (0.55 to 0.7), so the burst opens in a blink and spends its life on the rolling fire.
- **The vortex was a pink smear.** "A bright additive swirl on a lit floor is a pink smear." A dark, opaque disc under it, color [0.015, 0, 0.03], made its arms read.
- **Rings swept the screen.** The first shockwaves were white arcs. They now stay thin (width 0.04 to 0.07) and faint.
- **Rocks looked like orange plastic.** Debris is now dark (0x2c2622), with a glow that cools as exp(-2.2 t).

The one thing the notes call "the single most convincing cue in every pattern" is the light that rides with the projectile and slides over the floor.

## The result

game-vfx is six spells, 12 flipbooks, the runtime, the scripts and a demo arena at dusk, under MIT for the code and CC0 for the art. The 12 flipbooks are a 24 MB download as WebP (graphics memory is under Common questions). The meteor throws 44 rocks, leaves its rune circle for 2.6 s and sends up a 16 m light pillar.

![A meteor landing in the arena: a column of fire, black smoke, sparks and a glowing rune circle on the stone floor](https://cdn.patch.gg/media/sha256/c4/22/c422974028aa24751dcf11539d2a3f996ec614f8d7158ec2b0f54244411dea75 "The meteor in three.js.")

On game-vfx's Patch page you can pick a spell, switch between three cameras (Game, Low and Wide), change the speed and keep casting.

## Common questions

### How do you get clean frames on black from an AI video model?

Ask for it in every prompt and then clean up what's left. game-vfx ends each element prompt with "Pure black background (#000000) the whole time", keeps the element centered and away from the edges, and describes the clip opening and ending on black. The flipbook maker then sets a black level, turns the remaining dark pixels transparent, and fades the edges of each frame.

### How much graphics memory do AI flipbooks use?

All 12 flipbooks in game-vfx take about 256 MB of graphics memory once loaded, according to @rehan_shei, because each unpacks to a 2048 px sheet, even though they download as 24 MB of WebP. Load only the flipbooks your spells use. In @rehan_shei's words, the skill has "no compressed option yet."

### Does the method work in Unreal?

The method started in Unreal: @CanItCode's Seedance-to-Niagara workflow. game-vfx's flipbooks are plain 8 by 8 RGBA textures, but its runtime and spells are three.js only.

### Do you need to pay for video to try it?

No. The six spells and 12 flipbooks in the repo work without a fal key. You pay only when you film new elements or patterns.

## Try it

- Cast the six spells in the browser on game-vfx's Patch page, linked at the top.
- The skill, runtime and prompts: [git.patch.gg/rehan/game-vfx](https://git.patch.gg/rehan/game-vfx).
- [@rehan_shei's post on X](https://x.com/rehan_shei/status/2123977784280363342), with the demo video.
- [@CanItCode's Seedance-to-Niagara post](https://x.com/CanItCode/status/2120135112876580869).

```prompt
Make a small browser arena game in three.js with the game-vfx skill (git clone https://git.patch.gg/rehan/game-vfx.git): find a scene and a character in Patch's toolbox with pch search, give the player the fireball and chain lightning spells on two keys, and put three training dummies to hit. Run pch check and show me the screenshots, then publish it with pch publish.
```

## Credits

- game-vfx by @rehan_shei for Patch.
- The method after @CanItCode's Seedance-to-Niagara workflow; the inferno after HK RealTime VFX's UE5 fire spell.
- Flipbooks made with Seedance 2.5 by ByteDance on fal (CC0). Sound effects with ElevenLabs Sound Effects v3 on fal.
- Patch's mannequin (CC0), with clips from Quaternius' Universal Animation Library 1 and 2 (CC0).
- The arena: Poly Haven's Kiara 9 Dusk, Rock Tile Floor, Rock Boulder Dry, Rabdentse Ruins Wall, Gothic Statue, Boulder 01, Namaqualand Boulder 02 and Dead Tree Trunk 02 (CC0), and Soil Studio by Chiro Visuals through Patch's soil-and-grass block.

## Sources

- https://x.com/rehan_shei/status/2123977784280363342
- https://patch.gg/rehan/game-vfx
- https://git.patch.gg/rehan/game-vfx
- https://x.com/CanItCode/status/2120135112876580869
