FERRETGame engine over Babylon.js
Ferret

Physics look and budget

Skill ferret-physics-fx-tuning · download all skills · SKILL.md

When to use#

Making heat glow or water render; a frame over budget; choosing a tier.

The model#

Capabilities report numbers and own no look. physics-fx turns them into a picture: glow(scene, mesh, () => part.T), blackbody, incandescence (nothing is visible below about 800 K), waterMesh, fluidView, lampLight. Cost: it grows with how often a model steps and how finely it sub-steps. The tier table sets budgets; the Governor watches the step time and gives up detail in the order of its rules, taking it back when there is room.

Steps#

  1. Bind glow and lights to the state objects; give meshes a Standard or PBR material first.
  2. Slow models do not need 60 Hz: heat 2–10 Hz, liquids 10–20 Hz, reactor coast 1 Hz; step from an accumulator and pass the true interval.
  3. Raise maxSubstep (or maxStep) for coasts; keep fine sub-steps while something fast happens.
  4. When over budget remove in order: fx particles, step rates of slow models, sub-steps, off-screen simulation. Never the rigid-body step first.
  5. Read physics.info; add DegradeRules if the defaults do not fit.

Fire, smoke, explosions, splashes and steam as effects of their own (JSON definitions, a ladder from volume to dots, sound, fire spread) are @ferret/vfx: skill ferret-vfx.

Check afterwards#

Step time in physics.info stays under budget on the target tier; behaviour (not looks) is unchanged after degrading.

What usually goes wrong#

  • mesh "x" has no material to glow.
  • Governor never acts: no rule applies, or the step is under budget.
  • A rule has no effect: overridden at a narrower scope (the governor sets world scope).
  • A room the player left keeps stepping: stop it, and advance by the elapsed time on return.

Cloth on the GPU#

Cloth that is only drawn (flags, banners, sails, curtains) can run on WebGPU compute: ClothGpu.supported(engine) then new ClothGpu(engine, defs), step(dt) once a frame, createMesh(scene, i) draws from the GPU buffers; up to 512 particles and 8 sphere/plane/box colliders a cloth, no tearing and no body colliders (those stay on the CPU Cloth, which decides outcomes). Wait for ready (Babylon skips a dispatch until the pipeline has compiled). Nothing the fixed step reads may come from it.

Detail by relevance#

Before dropping detail for everything, drop it for what cannot be seen soon: RelevanceService classes (see ferret-perspective) decide which vessels, aircraft and effects are posed every frame, every third or fourth frame, or not at all. The flight model takes a sub-step rate per aircraft (Aeroplane.step(dt, hz), 200 by default). Check a change like this by statistics over many seeded runs (means within 5%, a single run within 15%), not by one run.

Files#

  • reference/fx.md — Colour and glow of hot parts, a mesh that follows a water surface, a particle liquid drawn as instances, and a light that follows a lamp.
  • reference/budgets-and-tiers.md — How much physics a device can afford: the tier table, the governor that gives up detail when the step runs long, custom degrade rules, and how to measure.
  • reference/api-physics-fx.md — every export of @ferret/physics-fx with signature and doc comment
  • recipes/tuning.md — Where the cost of the capabilities goes and which knob buys it back: sub-steps, step rates, off-screen sleep, and what to switch off first.