3D rigid body (spheres, convex hulls) physics simulator with friction with a vulkan renderer.
Graphics features:
- debug renderer (Vulkan 1.3)
- DrawIndexedIndirect rendering for 3d shapes
- stable cascaded shadow maps (CSM)
- soft shadows (PCF with adaptive sampling)
Physics features:
- rigid body dynamics simulation between arbitrary convex polyhedra
- sequential impulses solver (PGS), essentially, this is a port of box2d-lite to 3D
- stable stacking (one-shot manifolds with contact reduction and feature identification, warm starting)
- friction
- broad-phase (hierarchical grid)
WARNING for Windows users: totally untested on windows and MSVC, expect issues.
WARNING: the code is not production ready, it may be buggy, non-robust and unoptimized, it's definetely non-deterministic.
Dependencies (bundled):
- volk
- SDL3
- Dear ImGui
You also need Vulkan SDK (not bundled).
Building SDL3 may require additional dependencies depending on your OS.
cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build build
cd build
./demo
- WASD/ZX -- position control, Z/X are down/up, you can choose a body from the menu to control it instead
- Shift -- accelerate
- Escape -- close
- . -- toggle fullscreen
- u -- toggle UI
- m -- toggle mouse
- r -- restart simulation (Shift+R to restart and reduce time step for more accurate simulation in slow motion)
- p -- step 1 tick if physics stepping is enabled
- Physically Based Modeling, David Baraff
- Constraints Derivation for Rigid Body Simulation in 3D, Daniel Chappuis
- Polyhedral Mass Properties (Revisited), David Eberly
- Fast and Simple Physics using Sequential Impulses, Erin Catto
- box2d-lite, Erin Catto
- box2d, Erin Catto
- qu3e, Randy Gaul
- Collision Detection in 2D or 3D – Some Steps for Success, Randy Gaul
- Real-Time Collision Detection, Christer Ericson
- Robust Contact Creation for Physics Simulation, Dirk Gregorius
- The Separating Axis Test between Convex Polyhedra, Dirk Gregorius
- GJK implementation in 3D, vurtun
- Learn OpenGL
- Khronos Vulkan Tutorial
- The curious case of Vulkan Swapchain synchronization, Rob2309
- Yet another blog explaining Vulkan synchronization, Maister
- Vulkan examples, Sascha Willems (VulkanUIOverlay, shadowmappingcascade)
- Reversed-Z in OpenGL, nlguillemot
- OpenGL Cascaded Shadow Maps, johanmedestrom
- Cascaded Shadow Maps with Soft Shadows, Alex Tardif
- Improving shadow map utilization for cascaded shadow maps, Sebastian Sylvan
- GPU gems 2, Chapter 17, Efficient Soft-Edged Shadows Using Pixel Shader Branching, Yury Uralsky


