Dice Sim
Throw a handful of digital dice, watch them land, and get the total. The simulator supports common RPG dice, dice-pool notation, and two throw modes: a readable directed animation or full physics with rerolls for cocked dice.
I built it for large tabletop rolls, where I want the result quickly but still want dice to feel like dice. Enter values like 5d6+4d10+4, then adjust the dice, table, and renderer settings.
Building the studio and first die.
This study focuses on keeping the reported result tied to the dice the user can see. Directed mode rolls the values first, then animates each die into the matching orientation. Physics mode lets Rapier bodies settle naturally, then reads the top face, or the top vertex marker on a D4.
The scope is the dice roller itself, not a full tabletop rules engine. It covers D4, D6, D8, D10, D12, and D20; mixed notation and modifiers; pools of up to 100 dice; camera framing; cocked rerolls; and saved dice and scene appearances.
Large tabletop rolls should be quicker to resolve without losing the pleasure of seeing dice move.
The starting point was practical: I play a lot of tabletop games, especially Warhammer 40,000, where a single attack sequence can put a large pile of dice on the table. Sometimes I want the count quickly without pulling out real dice.
A plain random-number form would be faster, but also dull. The useful middle ground is a simulator that keeps the tactile feel of dice moving and settling, while making big pools easier to scan, total, and reuse.
It also gave me a reason to try Rapier. Smiley Spheres used a custom collision model that worked for round bodies, but dice need resting faces, edge cases, and a clearer way to recover from cocked landings.
Physics results are read from visible die orientations, with unclear landings exposed as rerolls.
Physics is the default path: Rapier bodies tumble inside the tray, settle, and then the resolver reads the upward face. Directed mode remains as a deterministic fallback when the animation needs a guaranteed readable landing.
- InputOne expression can combine several dice groups and a final modifier.
- ThrowPhysics mode rolls Rapier bodies by default; Directed mode remains available as a deterministic fallback.
- ReadThe resolver reads the upward face, or the top vertex on a D4, from each visible orientation.
- RecoverReadable dice stay on the table; only cocked or unclear landings are marked for reroll.
- ReportThe result popup and throw log read from the same roll record.
Physics stays available for pools of up to 100 dice; recovery rerolls only the dice that did not settle clearly.
Once a die settles on a readable result, it stays on the table and becomes part of the next pass. The reroll layout looks for open space around the kept pile instead of sending every unclear die through one fixed corridor. This reduces repeat collisions without replacing Physics with a directed animation.
The scene grows to the requested pool on demand. If frame times stay high, adaptive quality caps the pixel ratio and disables shadows for the rest of the session. An optional overlay exposes FPS, average and P95 frame time, draw calls, and triangle counts for inspection.
Scene, Dice, and Performance settings change presentation without changing the current roll.
Dice settings cover size, four material presets, body and mark colors, solid or ring pips, numbered D6 faces, and saved appearances. A contrast check corrects the mark color when a custom combination falls below the readability target.
Scene settings combine five presets with custom table colors and coordinated lighting. Performance settings show the current adaptive-quality state and can enable live renderer metrics when a throw needs closer inspection.
The right throw model depends on which part of the interaction needs to be inspectable.
Directed mode is better when the UI needs repeatable, testable landings. Physics mode is better when collisions and cocked dice are part of the experience, but it needs explicit recovery states so the result stays trustworthy.
Keeping the roll record separate from appearance and renderer settings also makes customization safer: the table can change without changing the result being inspected.
A fuller dice table
The simulator now handles mixed rolls, broader customization, and Physics pools of up to 100 dice.
- D10 support and smoothly rounded geometry across every supported die.
- Mixed expressions such as 5d6 + 4d10 + 4, with group subtotals and distinct colors or markers for repeated die types.
- Four materials, custom body and mark colors, D6 dots, rings, or numbers, saved appearances, and die sizing.
- Five coordinated scene presets, custom table colors, and a procedural studio surface.
- Physics pools of up to 100 dice, with readable dice kept in place while rerolls search for open table space.
- Adaptive rendering, optional live performance metrics, and retryable loading or WebGL failures.
- Dedicated Scene, Dice, and Performance settings without interrupting the current roll.
First public studyA working dice sim for D4, D6, D8, D12, and D20 pools.
- Dice notation for D4, D6, D8, D12, and D20 pools.
- Directed and Physics throw models with readable final results.
- Cocked-dice detection, manual rerolls, and appearance settings.
The core roller would stay rules-neutral; these directions add identity, deeper customization, and optional game layers.
- Personal dicePlace a custom mark, image, or emblem on the six face of a D6, then carry the same identity into saved appearances.
- Branded tablesAdd a logo or custom image to the tray surface, with controls for its scale, position, opacity, and contrast.
- Deeper customizationTune dice geometry, face marks, materials, lighting, and scene styling as one reusable dice-and-table setup.
- Optional game modesKeep the roller rules-neutral while offering opt-in helpers for Warhammer 40,000 dice pools and simple roll-off challenges where the highest result wins.
Tools, rules, and terminology behind the study.
- Three.js3D library used to render the scene and procedural dice.
- Rapier3D rigid-body physics engine used by the Physics throw model.
- Dice notationBackground on common NdS notation, dice pools, and modifiers.
- Warhammer 40,000 rulesOfficial rules and updates for the tabletop game behind the large-pool use case.