An easy explanation to Dual Contouring?

Started by
24 comments, last by JoeJ 6 years, 5 months ago
9 hours ago, QuesterDesura said:

If for example in my game a Cube gets placed by the player then I will create volume data containing the coordinates of the 8 edges, right?

Well, no. You volume data is usually a regular grid (can be 1-bit empty/full data, or floating point density values). You'd initialise the entire block of volume data to empty (i.e. zero). Then if the player places a cube, you'd intersect their cube with the volume data, and set each cell that intersects the box to full (i.e. one).

If you are looking for Minecraft-style terrain, where everything is cubes, then Dual Contouring is going to overcomplicate things significantly, and there are much simpler methods.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Advertisement

I'm looking for something

" rel="external">like this. They are using Dual Contouring. I think I now have gotten an Idea how Dual Contouring could be working and I will try to make a simple implementation and see if it works.

I have gotten some stuff working now. I used the Unity Editor to make it easier to see what I'm doing. I have "translated" the Code from the Github project in C# and changed/removed stuff that I don't understand. This is my first test:

WJALL5X.png

The small cubes presents voxels which are inside the mesh. Next steps will be to also let the algorithm run through the other sides and make a solid shape.

This is how it looks with a distance of -0.5 to all edges:

O7G4aqD.png

I think/I hope I have now understood how this algorithm works. I will post again if I encounter new problems or hopefully I can get some more results and share them.

13 hours ago, QuesterDesura said:

I'm looking for something

" rel="external">like this
.

The video looks like they do not use dual contouring, they only snap voxel vertices to the nearest point of target geometry, which should be a lot easier to implement. (Limitation is probably: You can not have two surfaces in one voxel.)

Unfortunately i do not remember a proper name or explantation of the technique, but there are a few around. Maybe someone else...

31 minutes ago, JoeJ said:

The video looks like they do not use dual contouring, they only snap voxel vertices to the nearest point of target geometry, which should be a lot easier to implement. (Limitation is probably: You can not have two surfaces in one voxel.)

Unfortunately i do not remember a proper name or explantation of the technique, but there are a few around. Maybe someone else...

They are using Dual Contouring which you can also see when you watch the full video, its also stated on their website.

@QuesterDesura -- can you please share your code on GitHub?

7 hours ago, QuesterDesura said:

They are using Dual Contouring which you can also see when you watch the full video, its also stated on their website.

Still disagree. See here (1:10):

 

The wireframe morphs directly from deformed geometry to voxels. No geometry is generated inside a voxel like dual contouring or marching cubes would do. 

Also the edge artefacts at the beginning when they build a structure from 3 boxes may hint this (missing vertex to represent multiple surfaces inside one voxel.)

Of course i do not know if that's all functionality they have.

Found what i have in mind, it's called 'Surface Nets'

https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2/

http://www.merl.com/publications/docs/TR99-24.pdf

Also found this about dual contouring, if you don't know yet, seems quite complete with code: http://ngildea.blogspot.co.at/

2 hours ago, JoeJ said:

Found what i have in mind, it's called 'Surface Nets'

https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2/

http://www.merl.com/publications/docs/TR99-24.pdf

Also found this about dual contouring, if you don't know yet, seems quite complete with code: http://ngildea.blogspot.co.at/

At 1:10 you can see that the cube is not being smoothed, if that would be Surface Nets then the cube wouldn't remain sharp also as I have already said: they clearly say on their website they are using Dual Contouring. But that's really not what I want to discuss here.

39 minutes ago, QuesterDesura said:

if that would be Surface Nets then the cube wouldn't remain sharp

You have not understood Surface Nets.

This topic is closed to new replies.

Advertisement