Deterministic XPBD Cloth/Ropes & WebGPU Mood Lighting Presets in Pulse
Curated WebGPU area environment lighting presets (AgX, volumetric fog, contact shadows, SSR, RT GI) paired with a 100% tick-deterministic cosmetic XPBD rope/banner solver stored in Pulse components.
- cloth
- rope
- xpbd
- verlet
- lighting
- tonemap
- agx
- ssr
- contact-shadows
- volumetric
- deterministic
- webgpu
No demo.
When to Use & Field Best Practices
Pulse gives every game a built-in WebGPU renderer with native agx tone mapping, physical sky, volumetric clouds & fog, contact shadows, screen-space reflections (ssr_intensity), RT global illumination (rt_gi_intensity), and depth of field — while strictly enforcing tick determinism (systems/*.ts forbids module-level mutable state, Math.random, Date, or Promise).
Two reliable craft patterns give Pulse worlds AAA-level visual richness without breaking witnessed scenarios:
- Flat-Key WebGPU Mood Presets (
world/*.area.jsonc):
- Always pair
tonemap: "agx"(hue-faithful bright highlights) withcontact_shadows: 0.65(0..1float strength — grounds characters and props cleanly) andtaa: true. - Use restrained
ssr_intensity(0.25–0.45) on rainy/polished stone areas and moderatert_gi_intensity(0.25–0.50) so shadow sides pick up natural bounce color without blowing brightness caps. - Keep
fog_densityinversely proportional to level width (0.002–0.005) and never invent nested or undocumented environment keys (Pulse warns atcompile).
- Tick-Deterministic Cosmetic XPBD Rope / Banner Physics (
contracts/+systems/):
- For standard capes, flags, and banners driven by area
environment.wind, Pulse ships a built-inClothcomponent (setCloth/clothImpulse). When you need custom wind fields, arbitrary tethers, or multi-point hanging chains, store each node's position and previous position inside acosmeticcomponent (cosmetickeeps pure visual motion outside gameplay save hashes while remaining 100% deterministic across replays!). - Integrate fixed-tick Verlet velocity +
3distance-constraint passes directly in a puresystem(...)using entityposas the moving anchor and deterministicMath.sinwind — zero module-level arrays or scratch objects!
Mathematical & Algorithmic Core
- Fixed-Tick Cosmetic Verlet Step (
Δ t = 1 / hz, dampingd ∈ [0.02, 0.08]): $p_k' = p_k + (1 - d)(p_k - p_k,prev) + (g + w(t))Δ t^2$ - Segment Length Projection for adjacent nodes
(a, b)with rest length $L$: $δ = frac\|b - a\| - Lmax(10^-4,\, \|b - a\|)(b - a), b ← b - δ$
Engine Implementation
1. Calibrated WebGPU Mood Presets (world/*.area.jsonc excerpts)
Copy one flat environment block matching your brief's mood (all keys verified against Pulse's area schema):
// Preset A — Rain-Slick Neon Undercity (SSR + AgX + Contact Shadows + Readable Rim)
{
"environment": {
"physical_sky": false,
"sky_zenith": "#12182c",
"sky_horizon": "#243554",
"sky_ground": "#0c101b",
"bg_color": "#12182c",
"sun_dir": [-0.35, -0.78, -0.52],
"sun_color": "#94c4ff",
"sun_intensity": 1.35,
"sun_shadows": true,
"ambient_color": "#384c78",
"ambient_intensity": 0.65,
"ibl_intensity": 0.65,
"fog_density": 0.0045,
"volumetric_fog_density": 0.006,
"volumetric_fog_rgba": "#2c4668",
"tonemap": "agx",
"exposure": 1.12,
"bloom_intensity": 0.32,
"bloom_threshold": 0.96,
"contrast": 1.08,
"saturation": 1.14,
"vignette": 0.22,
"contact_shadows": 0.65,
"ssr_intensity": 0.42,
"rt_gi_intensity": 0.35,
"taa": true
}
}
2. Deterministic Cosmetic XPBD Tail / Banner System (contracts/core.decl.jsonc + systems/cloth.ts)
Declare the pure cosmetic component and tuning in one pulse_declare call (which writes both into contracts/core.ts):
"component ClothChain { x1: num=0, y1: num=0, z1: num=0, px1: num=0, py1: num=0, pz1: num=0, x2: num=0, y2: num=0, z2: num=0, px2: num=0, py2: num=0, pz2: num=0, seg_len: num=0.45, tick: int(0..1000000)=0 } cosmetic""tuning cloth { gravity_y: -14.0, damping: 0.05, wind_amp: 3.2, wind_freq: 2.1 }"
Then update it inside a strictly pure, deterministic system (systems/cloth.ts) with zero module-level mutable variables:
import { query, system } from "pulse";
import { ClothChain, cloth } from "../contracts/core";
export const clothSystem = system("cloth", { after: "physics" }, (dt) => {
const dt2 = dt * dt;
const keep = 1.0 - cloth.damping;
for (const e of query(ClothChain)) {
const c = e.clothChain;
const ax = e.pos.x;
const ay = e.pos.y;
const az = e.pos.z;
// Initialize chain behind anchor on first tick
if (c.tick === 0) {
c.x1 = ax; c.y1 = ay - c.seg_len; c.z1 = az;
c.px1 = c.x1; c.py1 = c.y1; c.pz1 = c.z1;
c.x2 = ax; c.y2 = ay - c.seg_len * 2.0; c.z2 = az;
c.px2 = c.x2; c.py2 = c.y2; c.pz2 = c.z2;
}
c.tick = (c.tick + 1) % 1000000;
const phase = c.tick * dt * cloth.wind_freq;
const windX = Math.sin(phase + ax * 0.5) * cloth.wind_amp;
const windZ = Math.cos(phase * 0.8 + az * 0.5) * (cloth.wind_amp * 0.65);
// Verlet integration for node 1
const nx1 = c.x1 + (c.x1 - c.px1) * keep + windX * dt2;
const ny1 = c.y1 + (c.y1 - c.py1) * keep + cloth.gravity_y * dt2;
const nz1 = c.z1 + (c.z1 - c.pz1) * keep + windZ * dt2;
c.px1 = c.x1; c.py1 = c.y1; c.pz1 = c.z1;
c.x1 = nx1; c.y1 = ny1; c.z1 = nz1;
// Verlet integration for node 2
const nx2 = c.x2 + (c.x2 - c.px2) * keep + windX * 1.3 * dt2;
const ny2 = c.y2 + (c.y2 - c.py2) * keep + cloth.gravity_y * dt2;
const nz2 = c.z2 + (c.z2 - c.pz2) * keep + windZ * 1.3 * dt2;
c.px2 = c.x2; c.py2 = c.y2; c.pz2 = c.z2;
c.x2 = nx2; c.y2 = ny2; c.z2 = nz2;
// 3 XPBD distance relaxation passes (exact anchor at entity pos)
for (let it = 0; it < 3; it++) {
const dx1 = c.x1 - ax;
const dy1 = c.y1 - ay;
const dz1 = c.z1 - az;
const d1 = Math.sqrt(dx1 * dx1 + dy1 * dy1 + dz1 * dz1);
if (d1 > 0.0001) {
const s1 = c.seg_len / d1;
c.x1 = ax + dx1 * s1;
c.y1 = ay + dy1 * s1;
c.z1 = az + dz1 * s1;
}
const dx2 = c.x2 - c.x1;
const dy2 = c.y2 - c.y1;
const dz2 = c.z2 - c.z1;
const d2 = Math.sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2);
if (d2 > 0.0001) {
const diff = (d2 - c.seg_len) / d2;
c.x1 += dx2 * (diff * 0.35);
c.y1 += dy2 * (diff * 0.35);
c.z1 += dz2 * (diff * 0.35);
c.x2 -= dx2 * (diff * 0.65);
c.y2 -= dy2 * (diff * 0.65);
c.z2 -= dz2 * (diff * 0.65);
}
}
}
});
Browser, Mobile & Software-Renderer Budgets
- Zero Determinism Leaks: Because every node coordinate lives on
ClothChain(cosmetic) with zero module-levellet/var/arrays,pulse compileaccepts the system cleanly and allspec/scenarios/replays stay bit-for-bit reproducible. - Pair with Native
ProceduralChain/ProceduralMotion: Use Pulse's built-inProceduralChainfor simple character tails/banners andClothChainwhen you want custom wind fields or interactive gameplay-coupled sway. - Night Readability: Always keep
ambient_intensity >= 0.55and a non-blacksky_horizon(#243554) so dark neon scenes stay above the0.10brightness floor in captures.
Verification Checklist
- Run
compileand confirm zero determinism violations and zero unknown environment-key warnings. - Run
pulse_lookon"views play"and inspect the PNG to confirm crisp contact shadows, readable SSR floor sheen, and non-clippedagxhighlights. - Run
testto confirm every kept scenario remains witnessed.
Official references
- Matthias Müller / matthias-research — Ten Minute Physics XPBD Constraints (MIT)
- KhronosGroup — ToneMapping AgX & PBR Neutral Reference (Apache-2.0)
- Pulse Deterministic ECS & WebGPU Area Environment Reference
Open-source sources
- Takes an idea from Ten Minute Physics by Matthias Müller (MIT License): fixed-step XPBD Verlet distance constraint formulation
- Takes an idea from ToneMapping by Khronos Group (Apache License 2.0): AgX and hue-preserving display transform calibration
Games built with this guide carry these credits, and the licence notices they ask for, in their third-party notices.
More Pulse techniques
Atmospheric Vistas, Volumetric Clouds & Deterministic Feel in Pulse →
Composing Pulse physical sky, volumetric clouds, volumetric fog, water/foliage, and pure component-backed spring feel without violating sandboxed tick determinism.
Procedural Gait, Chain Motion & Readable Impact VFX in Pulse →
Expressive creature locomotion and impact readability in Pulse using ProceduralMotion, ProceduralGait, ProceduralChain, deterministic hit-flash/recoil components, and layered vfx bursts.
Deterministic Grid Push-Block & Tile Sweeps in Pulse →
Deterministic grid-based puzzle sweeps in Pulse using integer cell components, per-entity occupancy scans, and smooth fixed-tick interpolation.
Deterministic ECS Enemy Brains, Encounter Directors & Telegraphed Bosses in Pulse →
Data-oriented Pulse ECS enemy perception, orbit steering, attack-token encounter pacing, and multi-phase telegraphed boss state machines verified with headless pulse_run invariants.
Use verified techniques inside a real game
Describe your game idea for free or connect an MCP assistant to search and contribute techniques.