Project

Voxel Destruction

Tanish Makadia, Alexander Thaep

Overview.  Elastic deformation and fracture on voxel geometry using an implicit spring-mass system and compliant collision response.

Source
1 / …
Voxel DestructionDocumentation
All projects

Project

Voxel Destruction

Introduction

Physics simulations on 3D volumes typically utilize a finite element method (FEM) that represents objects as collections of tetrahedra. Nevertheless, video games like Minecraft and Teardown intentionally choose to use voxels ("volumetric pixels") rendered as cubes for their aesthetic appeal. In this project, we seek to create a fast system for simulating physics natively on hexahedral geometry instead of the tetrahedral geometry that is commonplace in FEM. In particular, we model collisions, elastic deformation, and fracture directly on voxelized geometry.

Note.

Alexander Thaep and I originally created this project for our CSCI 2240 (Advanced Graphics) final project at Brown University.


Voxels

We represent each voxel using a lattice spring model (LSM). Every voxel has eight corner nodes, each having its own position xi\mathbf{x}_i, velocity vi\mathbf{v}_i, and lumped mass mim_i. A voxel with edge length hh and density ρ\rho contributes ρh3/8\rho h^3/8 mass to each corner. If a node is shared by several voxels, then the corresponding mass contributions are accumulated.

Figure 2.1 (Node Masses)

System state is stored at the eight corners of each voxel.

Our model uses springs along each voxel edge, face diagonal, and body diagonal (in essence, every node has a spring between it and every other node). In total, each voxel has 28 springs.

Figure 2.2 (Lattice Spring Model)

12 edge springs

Our model uses springs along each voxel edge, face diagonal, and body diagonal.

Adjacent voxels are connected by a face link. Each link identifies four coincident corner pairs, which are merged into shared nodes. When neighboring voxels define a spring between the same pair of shared nodes, we store that spring once and scale its stiffness by the number of voxels that contributed it.

An interface is defined by four shared nodes; tensile strain across the interface is determined by the length of the link between voxel centroids.

Face links therefore encode both object topology and mechanical continuity. The distance between the two voxel centroids is used to compute the tensile strain defining when a link fractures. The fracture process later removes failed links and reconstructs the affected node and spring arrays.


Dynamics

Springs

For an edge e=(i,j)e=(i,j) with current vector xj−xi\mathbf{x}_j-\mathbf{x}_i, length ℓe\ell_e, rest length ℓe0\ell_e^0, unit direction de\mathbf{d}_e, and effective stiffness kek_e, the spring energy and force follow the classical Hookean model [Liu et al. 2013].

Ee(x)=12ke(ℓe−ℓe0)2,fi,e=ke(ℓe−ℓe0)de,fj,e=−fi,e.E_e(\mathbf{x})=\frac{1}{2}k_e(\ell_e-\ell_e^0)^2, \qquad \mathbf{f}_{i,e}=k_e(\ell_e-\ell_e^0)\mathbf{d}_e, \qquad \mathbf{f}_{j,e}=-\mathbf{f}_{i,e}.

Figure 3.1 (Spring Energy)

Restoring force equals the negative slope of the energy curve.

Implicit Step

Stiff springs make explicit integration unstable at useful time steps. We instead linearize an implicit Euler step and solve directly for the position increment Δx\Delta\mathbf{x}. With diagonal mass matrix M\mathbf{M}, time step Δt\Delta t, total force f\mathbf{f}, and stiffness matrix H=−∂f/∂x\mathbf{H}=-\partial\mathbf{f}/\partial\mathbf{x} (the Hessian of the total spring energy), the system follows the formulation in Section 3.1 of [Wu et al. 2022].

(M+Δt2H)⏟AΔx=Δt Mv+Δt2f⏟b.\underbrace{\left(\mathbf{M}+\Delta t^2\mathbf{H}\right)}_{\mathbf{A}} \Delta\mathbf{x} = \underbrace{\Delta t\,\mathbf{M}\mathbf{v} +\Delta t^2\mathbf{f}}_{\mathbf{b}}.

We avoid manifesting A\mathbf{A} due to its size. The implementation computes A(Δx)\mathbf{A}(\Delta\mathbf{x}) directly by summing the contribution from each spring. The preconditioned conjugate gradient (PCG) method can be used to solve the linear system A(Δx)=b\mathbf{A}(\Delta\mathbf{x})=\mathbf{b} efficiently. This matrix free form maps cleanly to PyTorch tensor operations and adapts immediately when fracture changes the spring graph.

The exact spring Hessian contains both axial and transverse terms (Eq. 3 of [Choi and Ko 2002]). We retain the positive semidefinite axial term

He≈ke dedeT,\mathbf{H}_e \approx k_e\,\mathbf{d}_e\mathbf{d}_e^\mathsf{T},

as a rank one approximation. Following the argument after Eq. 12 of [Choi and Ko 2002], we drop the transverse term because it becomes negative under compression. Omitting this term for every spring makes the linear operator symmetric positive definite (required for PCG).

Preconditioning

We evaluated the multilevel additive Schwarz preconditioner proposed by Wu et al. [2022], but did not use it in the final solver. Because fracture changes topology frequently, rebuilding its hierarchy offset the reduction in conjugate gradient iterations in our scenes. A Jacobi preconditioner, formed from the diagonal of A\mathbf{A}, produced lower overall solve time with much less setup work.


Fracture

An intact face link is tested using the distance between its two voxel centroids. If the rest spacing is hh, its tensile strain is

εab=∥cb−ca∥−hh.\varepsilon_{ab} = \frac{\left\|\mathbf{c}_b-\mathbf{c}_a\right\|-h}{h}.

The link is severed when εab\varepsilon_{ab} exceeds the material yield threshold. Because both voxels still reference the same four nodes, removing a face link is insufficient on its own. We must therefore rebuild the topology, duplicate nodes along the new fracture surface, regenerate unique springs and rest lengths, recompute lumped masses, and copy position and velocity from each former parent node.

Figure 4.1 (Broken Link)

Tensile strain across the interface is determined by the distance between voxel centroids.

After the face link from Figure 2.3 is severed under tension, the interface is rebuilt with independent nodes.

Shared nodes are rebuilt from a graph whose vertices are the 8V8V voxel corners. Each intact face link contributes four edges, one per coincident corner pair. Each connected component becomes one node. A shared node therefore splits only once broken links disconnect its corners. Components are labeled in parallel by label propagation combined with the pointer jumping approach used in the Shiloach–Vishkin algorithm [Shiloach and Vishkin 1982]. Every corner starts with its own index as its label. In one iteration, every corner is assigned the smallest label carried by it or its neighbors. Each label ℓ\ell is then replaced with the current label of corner ℓ\ell. Both steps are repeated until no label changes.

Figure 4.2 (Node Rebuild)

Label propagation and pointer jumping on an example corner graph, shown in 2D.

Collisions

Collision handling proceeds in four stages. 1) Produce collision candidates based on spatial locality, 2) define an oriented bounding box (OBB) around candidate voxels, 3) determine contact via the separating axis theorem, and 4) resolve penetration using a compliant positional constraint.

Figure 5.1 (Collision Pipeline)

C=∑i=18piqiT=UΣVT\mathbf{C}=\sum_{i=1}^{8}\mathbf{p}_i\mathbf{q}_i^\mathsf{T}=\mathbf{U}\mathbf{\Sigma}\mathbf{V}^\mathsf{T}R=U diag⁡ ⁣(1,1,det⁡(UVT))VT\mathbf{R}=\mathbf{U}\,\operatorname{diag}\!\left(1,1,\det(\mathbf{U}\mathbf{V}^\mathsf{T})\right)\mathbf{V}^\mathsf{T}
Each collision stage applied to two voxels at first contact, shown in a front view.

Candidate Pairs

Testing every pair of voxels would require quadratic work. Instead, we only test pairs of voxels that are in proximity of one another. To find these collision candidates, we search over an axis aligned bounding box that encloses every voxel centroid (with padding hh on each side). This box is partitioned into cubic cells of width hh, numbered in row-major order.

Each voxel is assigned to the cell containing its centroid. With nyn_y and nzn_z cells along the yy and zz axes of the box, the cell at integer coordinates (i,j,k)(i,j,k) within the box receives the key

κ(i,j,k)=i nynz+j nz+k.\kappa(i,j,k)=i\,n_y n_z+j\,n_z+k.

Sorting voxels by key gathers the voxels of each cell into one contiguous range that a binary search can retrieve. Collision candidates come from the 3×3×33\times3\times3 neighborhood of a voxel's cell. Since adjacency is symmetric, only a voxel's own cell and the 13 neighboring cells with larger keys are searched. These 14 searches visit every adjacent pair of cells exactly once. Pairs that share a corner node are already attached and are discarded.

Figure 5.2 (Cell Search)

Each voxel centroid lies in one cell of an axis-aligned grid with width h.

Row-major cell keys and the searched neighborhood of each voxel, shown in 2D.

Bounding Boxes

Each candidate voxel is represented by an oriented bounding box with a centroid, three orthogonal axes, and three half extents. Before contact testing, we recover the orientation of each box from its deformed voxel.

Let pi\mathbf{p}_i and qi\mathbf{q}_i denote current and rest corner offsets from their respective centroids. Following the shape matching construction in Eqs. 15 and 16 of [Macklin et al. 2014], we form the covariance matrix and compute its singular value decomposition.

C=∑i=18piqiT=UΣVT,R=U diag⁡ ⁣(1,1,det⁡(UVT))VT.\mathbf{C}=\sum_{i=1}^{8}\mathbf{p}_i\mathbf{q}_i^\mathsf{T} =\mathbf{U}\mathbf{\Sigma}\mathbf{V}^\mathsf{T}, \qquad \mathbf{R} = \mathbf{U}\, \operatorname{diag}\!\left(1,1,\det(\mathbf{U}\mathbf{V}^\mathsf{T})\right) \mathbf{V}^\mathsf{T}.

The determinant correction excludes reflections and yields the closest proper rotation. Projecting all eight current corner offsets onto the axes of R\mathbf{R} gives the box half extents.

Contact Test

The separating axis theorem states that two convex shapes are disjoint if and only if their projections onto some axis are disjoint. Two oriented boxes require fifteen tests: three face directions from each box and nine pairwise cross products of their edge directions. If every interval overlaps, the axis with minimum penetration supplies the contact direction and depth.

This geometric test replaces the centroid distance approximation described by Mazarak et al. [1999]. It remains plausible when voxels rotate, shear, or approach one another corner first.

Figure 5.3 (Separating Axes)

Projections of two boxes onto the axes normal to their edges, shown in 2D. A gap on any axis implies that the boxes are disjoint.

Projection

Each overlap becomes a positional constraint on penetration. We accumulate one Lagrange multiplier λ\lambda per candidate pair and update it with the extended position based dynamics (XPBD) rule from Eq. 18 of [Macklin et al. 2016]. With contact compliance γ\gamma, α=γ/Δt2\alpha=\gamma/\Delta t^2, penetration depth pp, and reciprocal of mean voxel mass ww, our sign convention gives

Δλ=p−αλ2w+α,λ←max⁡(0,λ+Δλ).\Delta\lambda = \frac{p-\alpha\lambda}{2w+\alpha}, \qquad \lambda\gets\max(0,\lambda+\Delta\lambda).

With λ\lambda clamped at zero, contacts can push but never pull. Macklin et al. [2016] treat contacts as rigid. We keep a small compliance instead, which gives each contact a stiffness of 1/γ1/\gamma. Projection runs for up to four passes per step. Each pass moves the corners of the two voxels along the contact normal by ±w\pm w times the change in λ\lambda after clamping. A corner shared by several contacts receives the average of their corrections.

Sliding is then limited by Coulomb friction. With friction coefficient μ\mu, normal correction δ=2wλ\delta=2w\lambda, and relative tangential displacement Δxt\Delta\mathbf{x}_t of the two centroids over the step, tangential displacement Δxt\Delta\mathbf{x}_t is reduced to

Δxt←(1−min⁡ ⁣(1,μ δ∥Δxt∥))Δxt.\Delta\mathbf{x}_t\gets\left(1-\min\!\left(1,\frac{\mu\,\delta}{\|\Delta\mathbf{x}_t\|}\right)\right)\Delta\mathbf{x}_t.

Each voxel receives half of the removed displacement. Sliding is effectively zeroed out when ∥Δxt∥≤μ δ\|\Delta\mathbf{x}_t\|\le\mu\,\delta and otherwise shrinks by μ δ\mu\,\delta. Voxel nodes below the ground plane are projected onto it, and Coulomb friction with δ\delta equal to penetration depth is applied instead.


Credits

Voxel models come from ephtracy's voxel model collection.


References

  • Tiantian Liu, Adam W. Bargteil, James F. O'Brien, and Ladislav Kavan. 2013. Fast Simulation of Mass-Spring Systems. ACM Transactions on Graphics 32, 6 (2013), Article 214. doi:10.1145/2508363.2508406
  • Botao Wu, Zhendong Wang, and Huamin Wang. 2022. A GPU-Based Multilevel Additive Schwarz Preconditioner for Cloth and Deformable Body Simulation. ACM Transactions on Graphics 41, 4 (2022), Article 63. doi:10.1145/3528223.3530085
  • Kwang-Jin Choi and Hyeong-Seok Ko. 2002. Stable but Responsive Cloth. ACM Transactions on Graphics 21, 3 (2002), 604–611. doi:10.1145/566654.566624
  • Yossi Shiloach and Uzi Vishkin. 1982. An O(log n) Parallel Connectivity Algorithm. Journal of Algorithms 3, 1 (1982), 57–67. doi:10.1016/0196-6774(82)90008-6
  • Miles Macklin, Matthias Müller, Nuttapong Chentanez, and Tae-Yong Kim. 2014. Unified Particle Physics for Real-Time Applications. ACM Transactions on Graphics 33, 4 (2014), Article 153. doi:10.1145/2601097.2601152
  • Oleg Mazarak, Claude Martins, and John Amanatides. 1999. Animating Exploding Objects. In Proceedings of Graphics Interface 1999. Canadian Human-Computer Communications Society, 211–218. doi:10.20380/GI1999.27
  • Miles Macklin, Matthias Müller, and Nuttapong Chentanez. 2016. XPBD: Position-Based Simulation of Compliant Constrained Dynamics. In Proceedings of the 9th International Conference on Motion in Games. Association for Computing Machinery, 49–54. doi:10.1145/2994258.2994272