Dual Countouring Editing Density Data

Hello,

I have implemented dual contouring based on various info I found online and also implemented it with the Jobs and BurstCompile systems. It seems to work really well.

I just have one question in regards to the actual editing of the terrain. How would you go about removing/adding primitive shapes to the terrain such as cubes/spheres, and how do you manage that data? The initial thought I have is to store the generated density data and modify that data when the player makes a change, but the dual contouring algorithm uses density from inside cells to calculate the zero crossing and normals, so I can’t store the modified density of each coordinate because I wouldn’t be able to calculate the densities inside the cell from it.

I’d appreciate if anyone could give any pointers or help in this. Also, I’d be willing to share my project if anyone is interested, just let me know :slight_smile:

Example picture (sphere density function with noise) attached

This went way over my head. Is the output of this thing a Mesh? Or is it some kind of optimized spatial data structure like a signed distance field?

If the output is a mesh, can you not just bolt on some premade meshes (and maybe merge the meshes via Mesh.CombineMeshes()? Sorry if this isn’t helpful, this is a bit out of my depth.

Nope, this is a mesh, but proceduraly generated to enable fast real-time updates