The issue that I'm having is working out how 3D Perlin Noise is used as a density function with the Dual Contouring Algorithm. I've found it difficult to find any Dual Contouring implementations or blogs/write ups that use or discuss the specifics of how they use 3D Perlin Noise with Dual Contouring to generate terrain.
I've managed to implement Dual Contouring with an implicit sphere so know its working correctly and have a basic idea of how density functions works (at least in a spheres case), have a basic knowledge of Perlin Noise (implemented the 3D version tested via texture output and basic cubic voxel terrain generation) and understand how to compute the gradient (analytical derivative in this case) for use with the QEF calculation.
I've experimented with a number of ways to try get relatively decent looking terrain with no success:
1) Generate the density values for the grid via Perlin noise (i.e. value < 1 is inside, > 1 is outside and 0 is on the contour) and then generate the intersection values (where the contour intersects the cube) for the cubes completely separately again using Perlin Noise, using the co-ordinate input as the index of the cube we're on with a minor offset. (Basically just generated a really cubic surface)
2) Use Perlin Noise in a similar way to the sphere function, generate the density grid via Perlin Noise and then for each intersection interpolate along the edge between the two nearby cubes density values until the Perlin Noise hits 0 (i.e. the exact point that the density function intersects the edge) then use the co-ordinate that triggered the 0 output from the Perlin Noise. (Again generates a cubic surface, think it might be because the interpolation usually triggers 0 when the co-ords hit an integer value i.e. on the Perlin latices edge.)
3) This is the one I've had most success with, similar to 2) except i keep the input values to the Perlin Noise within a 0.1 to 0.9 range i.e. kept within a single lattice. It feeds out ok values for some cubes but calculating the QEF (the averaged point for the cube) sends a fair amount of points well outside the range of a cube despite all the intersection points being well within the cube. I think its something to do with the way I use the Perlin Gradients, essentially I interpolate to find the co-ordinate that generates the 0 for the Perlin Noise return value, I then use the gradient(analytically derivative) from this co-ordinate and the culmination of all these sends the co-ordinate miles away.
Feel free to ask for more information to be posted up if its required I'll do my best, this is my first time posting so sorry if the post is sub-par.
tl;dr How is 3D Perlin Noise used as a density function to generate terrain in a Dual Contouring Algorithm? specifically in generating intersection points and normals for edges for the QEF calculation.
Edit: The new current method I'm trying (and failing) to use to integrate Perlin Noise using the perlin noise generator to fill up the initial density data, after this point for any edge intersection I do some simple linear maths to find the ratio on the line where the 0 crosses (so if a density value on one side was 0.5 and on the other side it was -0.5 the value given out would be that the 0 is 50% of the way between them so 0.5f). Once I have this value i simply add it on to the relevant co-ordinate to get the intersection point on that edge. After this point I use the intersection as input to calculate the Perlin Noises 3D Gradient (essentially just running the noise function with it as an input and calculating the analytically derivative using the method found here: 3D Perlin noise analytical derivative).
Once this is done the gradient and intersection values are fed into the QEF function, which uses SVD decomposition instead of the QR decomposition described as being more accurate within the original Dual Contouring Paper (found SVD to be simpler looking and it also sounded like it'd be less performance heavy from the paper).
A few screenshots to hopefully help a little by showing what it currently looks like. The first has the diagonal code commented out and the second has the Diagonal in place, the number immediately after all the prints of "vertex out of bounds" is the number of vertices outside of their cube.
https://i.stack.imgur.com/G0Wiv.jpg
The second with the diagonal division occurring: