First attempt to implement Dual Contouring
- 2D case on a simple grid
- mathjs for vector/matrix manipulation
- p5js to interactively visualize the result
Done:
- Partition space into a grid
- Add a surface function (noise-modulated circle)
- Iterate over vertices, marking densities (solid or air)
- Iterate over edges, marking surface intercept positions and normals
- Iterate over cells, positioning vertices by minimizing quadratic error function
- Iterate over cells, connecting adjacent vertices with faces (in 2d, just lines)
- Convert grid into quadtree, collapsing homogeneous regions
Most of the work is done in simplegrid.js
.
Not done:
- Multiple materials
- Adding/removing voxels
- Mesh simplification
Interactive demo (only tested in Chrome)