MLS-MPM (Material Point Method) in WebGL2: Snow, Jelly & Elastic-Plastic Fracture
Both Stable Fluids and D2Q9 Lattice Boltzmann live on purely Eulerian grids – great for smoke and water, terrible for fracturing snowballs or bouncing jelly that carry permanent material history. The Moving Least Squares Material Point Method (MLS-MPM) (Hu et al., SIGGRAPH 2018) gives you the best of both worlds: Lagrangian particles carry mass, velocity, and deformation gradient $\mathbf{F}_p$, while a temporary background Eulerian grid handles collisions and internal forces automatically – zero mesh tangling!
1. Particle-to-Grid (P2G) & SVD Snow Plasticity
Using quadratic B-spline weights $w_{ip}$ over a $3\times 3$ stencil, MLS-MPM fuses the APIC affine velocity matrix $\mathbf{C}_p$ and the first Piola–Kirchhoff elastic stress $\mathbf{P}(\mathbf{F}_p)$ into a single fused scatter pass:
That three-line SVD clamp is the secret behind Disney's Frozen snow: compress snow beyond $1 - \theta_c$ and it compacts permanently (hardening via $e^{\xi(1 - J_p)}$); stretch it past $1 + \theta_s$ and the elastic stress saturates so chunks cleanly fracture apart!
💻 GLSL: Fused MLS-MPM P2G Elastic Stress & Snow SVD Yield ClampGLSL / MLS-MPM
// MLS-MPM Core Loop (Hu et al., SIGGRAPH 2018): Fused P2G Momentum + Elastic Stress
// For each particle p with deformation gradient F_p and APIC affine matrix C_p:
mat2 U, S, V;
svd2x2(F_p, U, S, V);
// Plasticity clamp for Snow: singular values clamped to [1 - theta_c, 1 + theta_s]
S[0][0] = clamp(S[0][0], 1.0 - theta_c, 1.0 + theta_s);
S[1][1] = clamp(S[1][1], 1.0 - theta_c, 1.0 + theta_s);
F_p = U * S * transpose(V);
float J = S[0][0] * S[1][1];
// Fixed Corotated stress -> fused MLS-MPM affine transfer matrix
mat2 stress = 2.0 * mu * (F_p - U * transpose(V)) * transpose(F_p) + lambda * J * (J - 1.0) * mat2(1.0);
mat2 affine = (-dt * 4.0 * vol0 / (dx * dx)) * stress + mass * C_p;