I want to share a new asset I’ve been working on:
a Dual contouring package for Unity!
Demos
Play a test-bed, sand-box of it here!
and a fully deformable terrain world using Dual Contouring here.
Also a cubical, blocky world for all the Mine-craft fans.
Why would you want this?
Dual Contouring (D.C.) is one of a number of algorithms for extracting surfaces from scalar data sets. This makes it great for creating procedural objects or terrain where you want to modify them dynamically in generic ways (like blow a hole in a tank/wall/building/world/etc.) Marching Cubes (M.C.) is available in several packages for Unity currently (I would point you to my own package: Ruaumoko as an example). Despite “voxel” becoming synonymous with Mine-Craft like games it is in fact merely a data format and MC is actually really bad at making cubes (it loves to smooth them over). DC is much better, and the cubes don’t need to be oriented along the primary axes of the world!
Here’s an image that shows the difference in functionality between M.C. and D.C.:
The upper-right is what Cubes do and lower-right is what Contouring does. Basically it tries to honor sharp angles even if they fall into the center of a voxel.
My implementation is all in C# so it will run fine in Unity Indy! I’m planning on releasing it on the asset store once I’ve wrung the bugs out and worked on as much optimization as possible.
Below are a couple images of the same blocks rendered with Cubes and Contouring (from the demo).
Marching Cubes:
Dual Contouring:
The differences are subtle but distinctive. You can see how the DC likes to make flat sides in some places where MC chops them off (and the shader stretches badly on the flat walls).