# Investigation: Cage Deformation with Grids ## Problem Statement _Samples inside a mesh should follow the deformation of the mesh volume._ ## Conventional Solution [Mesh Deform Modifier](https://docs.blender.org/manual/en/latest/modeling/modifiers/deform/mesh_deform.html) - Slow preprocessing required. - Performance determined by both cage resolution and sample count. ## Proposed Method Idea: Use a grid to make sample deformation fast! 1. Rasterize deformation from mesh vertices into a grid. 2. Compute deformation in each grid cell ("blurring", "extension", see below). 3. Transfer deformation to samples with a simple lookup. If the grid relaxation/blurring can be fast enough this would decouple the sample count from performance, allowing higher sample counts than what would be feasible with mesh deform. This is because the transfer (step 3) is very cheap, compared to Mesh Deform where a full set of weights has to be computed for each sample. The grid resolution determines performance but not visual detail. ## Field Extension OpenVDB provides methods for "extending" fields across a fog or SDF volume based on some boundary conditions ([API methods](https://www.openvdb.org/documentation/doxygen/FastSweeping_8h.html)). This is probably the best method for generating a deformation vector for interior voxels. ![grid-deform](https://hackmd.io/_uploads/rJoaNkLHp.png) ## Math _True_ deformation is an unknown function $D(x)$. We compute an approximate $D_p$ for sample points described by grid interpolation: $$D_p = G_p(x) = \sum_i k_{p,i}(x) G_i$$ where $k_{p,i}(x)$ are the weighting factors for each sample and grid voxel and $G_i$ are the deformation vectors stored in grid voxels. Grid deformation is defined at voxel centers $c_i$ by projection from the surface: $$G_i = S_{closest}(c_i)$$ This introduces an error