Special effects
Skill ferret-vfx · download all skills · SKILL.md
When to use#
Anything that happens in a scene and is not a body: a campfire, a burning house, a shell bursting, a splash, a fountain, steam, dust behind a truck, a lightning stroke, a shield. Not for a level's ambient motes, nor the glow of hot parts (ferret-physics-fx-tuning).
The model#
An effect is a JSON definition (parameters with units, emitters, modules, optional volume, impostor, dot, light, decal, sound) compiled once; VfxSystem steps it in the fixed 60 Hz step from a seed, so every peer makes the same particles; VfxBabylonView draws it on a ladder chosen by size on the screen. A value set by hand always wins over the physical one; an unset one comes from the energy, the fuel or the material, never a table.
Steps#
const sys = new VfxSystem(); sys.registerAll(FULL_CATALOG)(orFIRE_CATALOG,BLAST_CATALOG,WORLD_CATALOG,ENERGY_CATALOG);sys.host = { wind, groundHeight }from the flow and terrain of the level.- By hand:
sys.spawn('fire.campfire', { at, seed, params: { heat: 2e5 } });vfx.list(command) shows each effect's parameters, units and limits. By physics:driveFromPhysics(world.events, sys, { materialOf, dustAt }). - Draw:
new VfxBabylonView(scene, sys, camera, { soft: true, supports: ['particles','impostor','dot'] }); each fixed stepsys.step(1/60), each frameview.draw({ cameraPosition, fov, heightPx, tier, dt, night }). - Fire:
FireSpread(grid, env)withsetFuel,ignite(cell, t),step(t);FireBridge(sys, fire, { stride })withaddTarget({ id, at, material, burn })for what can catch fire; callbridge.heat(bridge.burning(), dt)andbridge.apply(fire.step(t))in the fixed step. - Sight:
new SmokeSight(sys).transmittance(a, b)is 1 clear to 0 hidden; the AI and visibility rays ask it. - Sound:
defineSynthPresets(audio, { names: SOUND_PRESETS }), aVfxSoundPlayerwithspawned/stopped/updatefor each instance as it starts and ends; delay and filtering come from the distance. - Network:
new VfxReplica(sys, { peer, send, fire, bridge })andinstallVfxNet(net, replica); start effects throughreplica(orreplica.asSim()for the drive). Particles never cross the wire. - Editing:
registerVfxCommands(registry, new VfxSession(sys)); a level's manifest takes avfxblock{ defs, place }.
Check afterwards#
vfx.stats and view.stats.rungs show what runs; the ?vfx viewer (vfx.view, vfx.screenshot) gives the same picture from the same seed; vfx.undo restores the picture before a placement; a blast 120 m away is heard about 0.35 s after the flash. Run only single test files (packages/vfx/test).
What usually goes wrong#
- Nothing is drawn:
sys.stepis not in the fixed step,view.drawis not called each frame, or the name is not registered (sys.has(name)). - "Outside its limits" or "no parameter":
vfx.listhas the names, units and limits. - The frame drops in a big fire: about 1 ms per 1000 particles; give the scene a governor that stops the farthest effects over a budget, use
stride, lowermaxParticles. - Peers differ: an effect was started from a local event instead of through the replica, or the sim was stepped from the frame time.
- Smoke hides no one:
SmokeSightis on anotherVfxSystemthan the stepped one. - No dust or splash from a physics event: the body was below
minImpactEnergy, or the effect is not registered. - Distant fires wink out: the view lacks
supports: ['impostor','dot']. - Nothing in a UE build: that side is unfinished (plan F15); the browser build works.
Files#
reference/vfx.md— Fire and smoke, explosions and weapons, water, steam and dust, energy. An effect is a JSON definition with parameters and expressions; physics fills the parameters, a ladder of volume, GPU particles, impostors and dots draws it, sound follows from the same numbers.reference/api-vfx.md— every export of@ferret/vfxwith signature and doc commentreference/api-vfx-2.md— every export of@ferret/vfxwith signature and doc commentreference/api-vfx-3.md— every export of@ferret/vfxwith signature and doc comment