I have my own implementation of dual contouring. Right now I am getting the following output:
This is decent, but I am trying to get a better result (i.e. try to reduce the low level voxel noise as much as possible).
The core of the problem is, once we know which cells are connected, we need to pick, for every cell, a suitable location for the vertex corresponding to it.
You want the green point.
My algorithm for this part of dual contouring is:
Start at the cell center, define the loss function:
$$L(X) = \lambda f(X)^2 + \|X - c\|^2$$
Where $f$ is the sdf function we are countouring and $c$ is the cell center.
I calculate the numeric gradient of that function and for 5 iterations, starting at $X_0=c$ do:
$$X_i+1 = X_i - \epsilon g(X_i)$$
Then once dual contouring is done I do a box average of my vertices on the final mesh.
Stuff I have tried without success:
- Increase Iteration numbers (same result)
- decrease $\epsilon$ (same result)
- Increase $\lambda$ (currently 1000, breaks things when larger)
- Have a larger $\epsilon$ that decreases over time (same result).