Destructible environments are one of the hardest problems in game rendering. A traditional mesh must be re-triangulated whenever the surface changes, which is expensive and creates unpredictable triangle counts. SDFs handle destruction naturally because carving a hole is just a CSG subtraction, one operation on a scalar field. This article covers the carving operation, how the SDF tree scales as deformations accumulate, the Marching Cubes extraction step that turns the field back into triangles, and the hybrid approaches engines use in practice.
For the CSG operators and the sphere tracing basics, start with the Signed Distance Fields overview . For the engine-wide context, see SDFs in game development .
Carving Destructible Terrain with CSG Subtraction
When an explosion removes a spherical chunk of terrain, the SDF updates with a single operation:
float crateredTerrainSDF(vec3 p) {
float terrain = terrainBaseSDF(p);
float crater = sphereSDF(p, explosionCenter, explosionRadius);
return max(terrain, -crater); // CSG subtraction
}
The max(a, -b) pattern subtracts volume B from volume A. Any point that was inside both the terrain and the explosion sphere is now outside (its distance becomes positive), carving a hole exactly where the explosion occurred. The update costs one extra primitive per explosion, not a full re-triangulation.
A worked example shows the subtraction acting on real values. Take a flat terrain where the base SDF is the plane (negative below the surface, positive above) and an explosion centered at with radius 3. The crater SDF is .
Test three points:
- : terrain (1.5 units below the surface), crater (inside the blast). Combined: . The point that used to be solid ground is now 1.5 units outside the terrain. It was carved away.
- : terrain , crater . Combined: . Still on the surface, unchanged.
- : terrain , crater . Combined: . Just outside the blast edge, unchanged.
The first point is the carving itself: ground that was solid is now empty. The other two show that untouched terrain keeps its exact distance values, so the combined field remains a valid SDF everywhere except where the sphere overlaps the terrain.
This scales to multiple sequential deformations. Each new crater adds one more term to the SDF expression. After 50 explosions, the SDF is a tree with 51 primitives (1 base terrain + 50 subtraction operations), and evaluating it at a point costs 51 primitive distance calculations. That is linear growth in the number of deformation events, but constant per evaluation, with no mesh topology to maintain. When many craters overlap, the tree stays correct because each max term only ever makes a point more outside, which is exactly the semantics of removing material.
Mesh Extraction for Rendering
SDF-based terrain still needs to become triangles for the rasterization pipeline, unless you are rendering entirely with ray marching. The standard bridge is Marching Cubes, which extracts an isosurface from a sampled scalar field. Since the SDF encodes the surface as the zero level set, Marching Cubes naturally extracts a triangle mesh approximating the current terrain shape.
The full pipeline looks like this:
- Maintain a base terrain SDF, possibly sampled from a heightmap or procedural noise.
- Apply CSG subtraction for each deformation event (explosions, digging, construction).
- Sample the combined SDF on a 3D grid around the deformed region.
- Run Marching Cubes on those samples to produce a triangle mesh.
- Upload the mesh to the GPU for rasterization.
Steps 3 through 5 repeat every frame in the affected region, but the grid is typically small (64³ or 128³) and the extraction is fast enough for real-time use. Games like Astroneer and Deep Rock Galactic use variations of this pipeline for their destructible terrain.
Two tuning decisions dominate the extraction quality. The first is grid resolution: doubling the resolution multiplies the sample count by 8 in 3D, so the grid size is a direct memory and time budget. The second is where the grid lives: extracting only around the deformed region keeps the cost bounded regardless of how large the level is, while re-extracting the whole world every frame does not scale. The tradeoffs of sampling and interpolation are the same ones that govern baked signed distance fields ; the Marching Cubes hub covers the extraction algorithm itself.
Hybrid Approaches
Not every destructible surface needs a full volumetric SDF. A common hybrid is to represent terrain as a 2D heightfield with a 2D SDF encoding overhang and cave information. The heightfield handles the primary surface at low cost, and the SDF handles concave features and tunnels that a heightfield cannot represent.
Another hybrid stores the deformation history as a list of subtracted primitives (spheres, boxes, capsules) and evaluates them at runtime only where needed. Far from any deformation, the base terrain evaluates quickly. Near deformations, the extra CSG terms add cost but only in the regions where detail is high. This is the same principle as the SDF tree from the carving section, but with the tree kept lazy: primitives are only consulted when a query lands inside their bounding region.
The hybrid that appears most in shipped games combines all of these: a heightfield for the broad terrain, a small volumetric SDF volume for the region around active deformations, and a list of deformation events that can be replayed to rebuild either representation when the level is saved or loaded.
Summary
Destruction is where the SDF’s representational strengths line up most cleanly:
- Carving is a CSG subtraction,
max(terrain, -crater), that removes exactly the exploded volume and stays a valid distance field everywhere else. - Scaling is linear in the number of deformation events and constant per evaluation, with no mesh topology to repair.
- Rendering re-extracts triangles with Marching Cubes from a small grid around the deformed region.
- Hybrids combine heightfields, lazy deformation lists, and volumetric SDFs to keep cost proportional to actual damage.
The same field that stores the carved terrain also answers the collision queries players fire into it, and the shadow and AO passes that light it.