Wishlist on Steam

The Mechanics Library · 45 tutorials · 69 live demos

How games actually work.

Long-form tutorials on the systems behind games. Each one walks through the idea, the maths and the code, then hands you a demo to break.

Showing all 45

The live demo from Screen Space Ambient Occlusion (SSAO).

No.45Rendering & shaders

Screen Space Ambient Occlusion (SSAO)

Screen Space Ambient Occlusion (SSAO) darkens corners, crevices, and contact points in real time by sampling the depth buffer around each pixel. This article explains the complete algorithm — from the AO integral and G-buffer setup through hemisphere kernel generation, noise rotation, the

1 demo13 min read

The live demo from Skeletal Animation & Skinning.

No.44Animation & cameras

Skeletal Animation & Skinning

Skeletal animation and skinning are the foundation of every character animation in 3D games — discover how bone hierarchies, inverse bind matrices, and linear blend skinning transform static meshes into fluidly moving characters in real time.

1 demo13 min read

The live demo from Third-Person Camera Systems.

No.43Animation & cameras

Third-Person Camera Systems

Learn how third-person camera systems work in games, from basic follow cameras to smooth exponential damping and collision avoidance with raycasting. Explore the math and interact with a live Three.js demo.

1 demo9 min read

The live demo from Navigation Meshes (NavMesh).

No.42AI & navigation

Navigation Meshes (NavMesh)

Learn how navigation meshes decompose walkable game environments into convex polygons for fast, smooth AI pathfinding — from Recast generation to the funnel algorithm.

1 demo8 min read

The live demo from Procedural Dungeon Generation.

No.41Procedural generation

Procedural Dungeon Generation

Learn how roguelikes generate unique dungeon layouts every run using Binary Space Partitioning (BSP) trees, with an interactive 3D demo you can explore and regenerate.

1 demo8 min read

The live demo from Procedural Locomotion.

No.40Animation & cameras

Procedural Locomotion

Learn how procedural locomotion generates lifelike walking animations at runtime using step triggering, gait coordination, and two-joint inverse kinematics — no pre-baked animation clips required.

1 demo8 min read

The live demo from Volumetric Lighting (God Rays).

No.39Rendering & shaders

Volumetric Lighting (God Rays)

Learn how volumetric lighting and god rays work in games, from the physics of light scattering and the Beer-Lambert law to the screen-space radial blur technique used in modern game engines.

1 demo7 min read

The live demo from Octrees.

No.38Spatial structures & culling

Octrees

Octrees partition 3D space into eight recursive subdivisions, enabling lightning-fast spatial queries for collision detection, frustum culling, and more. Learn the algorithm, the math, and explore an interactive 3D visualization.

1 demo8 min read

The live demo from Poisson Disk Sampling.

No.37Procedural generation

Poisson Disk Sampling

Learn how Poisson disk sampling generates natural, evenly-spaced point distributions for placing objects in game worlds — from trees and rocks to spawn points and audio sources — using Bridson's elegant O(n) algorithm.

1 demo9 min read

The live demo from Normal Mapping.

No.36Rendering & shaders

Normal Mapping

Normal mapping lets flat polygons appear richly detailed by encoding surface normals in a texture. Learn the math behind tangent space and the TBN matrix, walk through a GLSL implementation, and interact with a live Three.js demo that generates a brick normal map in real time.

1 demo8 min read

The live demo from Bloom (Post-Processing).

No.35Rendering & shaders

Bloom (Post-Processing)

Learn how bloom post-processing creates the signature cinematic glow seen in nearly every modern game. We break down the complete rendering pipeline — brightness extraction, Gaussian blur, and HDR compositing — with math, shader code, and an interactive Three.js demo.

1 demo8 min read

The live demo from Toon Shading (Cel Shading).

No.34Rendering & shaders

Toon Shading (Cel Shading)

Learn how toon shading (cel shading) works — from quantized diffuse lighting and hard specular cutoffs to inverted-hull outlines — and explore the technique with an interactive Three.js demo.

1 demo8 min read

The live demo from Parallax Scrolling.

No.33Rendering & shaders

Parallax Scrolling

Learn how parallax scrolling creates the illusion of depth by moving background layers at different speeds. Explore the math, implementation patterns, and an interactive Three.js demo of this classic game development technique.

1 demo7 min read

The live demo from Metaballs & Implicit Surfaces.

No.32Rendering & shaders

Metaballs & Implicit Surfaces

Explore how metaballs use overlapping scalar fields to create organic, blobby shapes that smoothly merge and separate. Learn the math behind implicit surfaces, falloff functions, and real-time GPU rendering techniques used in games like LocoRoco and World of Goo.

1 demo10 min read

The live demo from Flow Fields.

No.31AI & navigation

Flow Fields

Learn how flow fields provide efficient pathfinding for hundreds of agents simultaneously by computing a single vector field that guides all movement, using the same three-layer algorithm behind RTS games like Supreme Commander.

1 demo9 min read

The live demo from Projectile Trajectories & Ballistics.

No.30Physics & simulation

Projectile Trajectories & Ballistics

From grenade arcs in Halo to artillery shells in World of Tanks, projectile ballistics is one of gaming's most fundamental physics mechanics. Learn the kinematic equations, inverse aiming solutions, and arc visualization techniques that power it all.

1 demo8 min read

The live demo from GPU Instancing.

No.29Rendering & shaders

GPU Instancing

GPU Instancing collapses thousands of draw calls into one by uploading a single mesh to the GPU and supplying a buffer of per-instance transforms — enabling vast forests, armies, and asteroid fields to render at full speed with minimal CPU overhead.

1 demo10 min read

The live demo from Voronoi Diagrams.

No.28Procedural generation

Voronoi Diagrams

Voronoi diagrams partition space into cells based on nearest-neighbor distance to seed points, powering procedural map generation, real-time fracture physics, Worley noise textures, territory control systems, and GPU-accelerated signed distance fields across virtually every genre of game.

1 demo9 min read

The live demo from Verlet Integration.

No.27Physics & simulation

Verlet Integration

Verlet integration is a numerically stable physics simulation technique that powers cloth, rope, and ragdoll physics in games. This article breaks down the position Verlet formula, Thomas Jakobsen's constraint relaxation method, and how a three-line integration loop can produce convincing

4 demos10 min read

The live demo from Behavior Trees.

No.26AI & navigation

Behavior Trees

Behavior Trees are the hierarchical AI architecture behind enemies in Halo, The Last of Us, and Unreal Engine — learn how Selectors, Sequences, and Leaf nodes combine to create believable, modular AI with a live interactive demo.

1 demo10 min read

The live demo from Ray Marching & Signed Distance Fields.

No.25Rendering & shaders

Ray Marching & Signed Distance Fields

Discover how Signed Distance Fields and ray marching let you render complex 3D shapes using pure mathematical functions — no meshes, no vertices, just elegant equations running entirely on the GPU.

1 demo9 min read

The live demo from Separating Axis Theorem (SAT).

No.24Physics & simulation

Separating Axis Theorem (SAT)

The Separating Axis Theorem is the mathematical backbone behind precise convex-shape collision detection in countless games. Learn how it works, how to compute the Minimum Translation Vector for physics resolution, and see it in action with a fully interactive demo.

4 demos10 min read

The live demo from Wave Function Collapse.

No.23Procedural generation

Wave Function Collapse

Wave Function Collapse is an elegant constraint-satisfaction algorithm that generates infinite variety from simple tile rules — powering the remarkably natural-looking worlds of games like Townscaper, Bad North, and Caves of Qud.

1 demo10 min read

The live demo from Water Simulation.

No.22Physics & simulation

Water Simulation

Water simulation is one of the most visually striking — and mathematically rich — techniques in game development. Learn how Gerstner waves, FFT-based ocean rendering, and the shallow water equations work together to create convincing real-time water.

1 demo9 min read

The live demo from Cellular Automata.

No.21Procedural generation

Cellular Automata

Cellular automata use dead-simple neighbor-counting rules to transform random noise into organic cave systems — one of procedural generation's most elegant algorithms, used everywhere from Spelunky to Dwarf Fortress.

1 demo10 min read

The live demo from Marching Cubes.

No.20Procedural generation

Marching Cubes

Marching Cubes converts a 3D scalar field into a smooth triangle mesh in real time — it's the algorithm behind metaballs, volumetric terrain, and procedural cave generation in modern games.

1 demo7 min read

The live demo from Noise Functions (Perlin & Simplex).

No.19Procedural generation

Noise Functions (Perlin & Simplex)

Discover how Perlin and Simplex noise functions generate the coherent randomness behind procedural terrain, textures, and animations in modern games — complete with an interactive 3D terrain generator you can tune in real time.

1 demo9 min read

The live demo from Occlusion Culling.

No.18Spatial structures & culling

Occlusion Culling

Occlusion culling identifies and discards geometry the camera cannot possibly see — hidden behind walls, buildings, or terrain — before it ever reaches the GPU, slashing draw calls and unlocking dramatically higher scene complexity.

1 demo9 min read

The live demo from Shadow Mapping.

No.17Rendering & shaders

Shadow Mapping

Shadow mapping is the foundational two-pass technique behind real-time shadows in virtually every modern 3D game — a clever algorithm that asks whether the light can see each pixel, with bias tricks, PCF filtering, and cascaded variants for large open worlds.

1 demo7 min read

The live demo from Level of Detail (LOD).

No.16Spatial structures & culling

Level of Detail (LOD)

Learn how Level of Detail (LOD) systems automatically swap between high- and low-complexity meshes as objects move closer or farther from the camera, and why this technique is the backbone of performance in every large-scale 3D game.

1 demo9 min read

The live demo from Frustum Culling.

No.15Spatial structures & culling

Frustum Culling

Frustum culling is the foundational visibility technique that stops your GPU from drawing objects the camera can’t see. Learn the math behind view frustums, plane extraction, bounding volume tests, and hierarchical culling used in every modern 3D game engine.

1 demo8 min read

The live demo from Rigid Body Physics.

No.14Physics & simulation

Rigid Body Physics

Rigid body physics powers every tumbling crate, bouncing ball, and ragdoll in games. Learn how impulse-based collision response works—the math behind every major physics engine—and explore it live in an interactive 3D simulation.

1 demo7 min read

The live demo from Finite State Machines.

No.13AI & navigation

Finite State Machines

Discover how Finite State Machines power enemy AI in games from Pac-Man to Dark Souls, and learn to build your own FSM with states, transitions, and hierarchical extensions.

1 demo8 min read

The live demo from Steering Behaviors.

No.12AI & navigation

Steering Behaviors

Discover how Craig Reynolds' steering behaviors — Seek, Flee, Arrive, and Wander — give game characters natural autonomous movement using elegant vector math you can implement in an afternoon.

1 demo7 min read

The live demo from Spatial Hashing.

No.11Spatial structures & culling

Spatial Hashing

Spatial hashing transforms O(n²) collision detection into an O(n) operation by dividing the world into a uniform grid and using a hash map to find only nearby object pairs — cutting tens of thousands of checks down to dozens every frame.

1 demo9 min read

The live demo from Particle Systems.

No.10Physics & simulation

Particle Systems

Particle systems power every explosion, flame, and magical effect in games. Learn the math of particle motion, emitter types, object pooling, and GPU rendering techniques that let thousands of simultaneous particles run at 60 fps.

1 demo10 min read

The live demo from Rope & Cloth Physics.

No.09Physics & simulation

Rope & Cloth Physics

Discover how games simulate ropes, capes, and flags using Verlet integration and distance constraints — a surprisingly elegant algorithm that produces remarkably realistic results in real time.

1 demo7 min read

The live demo from Inverse Kinematics.

No.08Animation & cameras

Inverse Kinematics

Inverse Kinematics (IK) is the mathematical technique behind natural-looking limb movement in games — discover how the FABRIK algorithm elegantly solves the chain-reaching problem and how to implement it from scratch.

4 demos9 min read

The live demo from Raycasting.

No.07Spatial structures & culling

Raycasting

Raycasting is the algorithm that conjured 3D corridors in Wolfenstein 3D and still drives mouse-picking, AI line-of-sight, and real-time ray-traced shadows today. Learn the DDA algorithm from first principles and see it visualized live in an interactive demo.

4 demos8 min read

The live demo from A* Pathfinding.

No.06AI & navigation

A* Pathfinding

A* (A-star) is the most widely used pathfinding algorithm in game development. Learn how it combines exact movement costs with heuristic estimates to efficiently find shortest paths through any environment.

4 demos8 min read

The live demo from Bézier Curves.

No.05Animation & cameras

Bézier Curves

Bézier curves power smooth camera paths, projectile arcs, UI animations, and spline geometry across countless games. This article breaks down the math from linear interpolation to De Casteljau's algorithm, with an interactive demo where you sculpt the curve in real time.

4 demos8 min read

The live demo from Procedural Terrain Generation.

No.04Procedural generation

Procedural Terrain Generation

A deep dive into procedural terrain generation: how Perlin noise, fractal Brownian motion, and domain warping combine to produce infinite, believable landscapes — plus a live interactive Three.js demo you can explore and reseed in real time.

1 demo9 min read

The live demo from Quadtrees.

No.03Spatial structures & culling

Quadtrees

Quadtrees are a spatial partitioning data structure that dramatically accelerate collision detection and scene queries by recursively dividing 2D space — learn the algorithm, the math, and see it in action with an interactive Three.js demo.

4 demos8 min read

The live demo from Spring Physics.

No.02Physics & simulation

Spring Physics

Spring physics powers countless game effects — from bouncy platforms and swaying ropes to camera lag and ragdoll characters. Learn the math behind Hooke's Law, numerical integration, and spring chains, then see it all in an interactive simulation you can grab and drag.

4 demos8 min read

The live demo from Flocking with Boids.

No.01AI & navigation

Flocking with Boids

Discover how three simple rules — separation, alignment, and cohesion — create stunningly realistic flocking behavior used in games from Half-Life 2 to The Witcher 3.

1 demo6 min read

Shader lessons · GLSL in the browser

Prefer writing shaders to reading about them?

Thirty step-by-step GLSL lessons run live in the browser, from a first gradient to raymarched soft shadows.

Open the shader lessons
Esc