Research and Propsals for Comments
Hello again.
I have been getting back into my volume based rendering in rust and wanted to discuss some of the research with you.
Bakers
I have been looking at other surfacing algorithms and some of which I think we can implement into the bakers.
- Marching Tetrahedra
- Similar to marching cubes but meshes are always manifold
- Uses about 4x the number of verticies
- Transvoxel
- This generates smooth meshes with LOD so that further aways vertices are further apart
- This might be nice to add for non-block like terrain
- Dual marching cubes
- Like marching cubes but creates fewer vertices on the planes then at the corners
Links:
- voxel tools go code for a similar project to this (includes transvoxel)
- smooth terrain blog blog post on making smooth terrain from volume data (includes comparison of different surfacing methods)
- voxel gfx Page that explains how to implement dual marching cubes as well as other aspects like trilinear shaders and octtrees for the LOD
Chunk Trees
With regards to a tree structure to hold chunks the most interesting one I've seen is this one by voxel gfx it holds the chunks in an octtree where each level represents higher detail. This has the nice benefit of allowing LODS to page in and out
On a more general structure I think we could use a method like dual grid to help work out the neighbors in a chunk tree
Density
Currently the chunks are all integer values on a grid. But it might be more useful to represent them as densities on a grid. There are a few benefits to this:
- Early exit
- A density map is meshed by finding the surface of an isovalue, if the density at a voxel is very far away from this isovalue we could assume that neighboring voxels are also likely to be far away from the isosurface and can be skipped.
- Interpolation
- We can interpolate values off of the grid points, this could be useful for working out arbitary LOD levels from the same source data
- Gradients
- We can work out gradients. This can be used for the normal calculations and can be used for more complex meshing algorithms like Dual Contours that require gradients.
Bakers
I need to read the links that you send me, but some things will be easier to implement right now, like the marching tetrahedra and dual marching cubes, there are also other bakers I wanted to implement (dual contouring, surface nets, etc).
Chunk Trees
The chunk trees it looks interesting, need to check out, but a quick glance at the links seems to be pretty solid.
Density
I need read more about this topic, because I'm not sure if I understand this correctly, isn't this something similar to the heightmap?
Density is in 3 dimensions. Well any number of dimensions really. Currently we just have 0 outside 1 inside. But with density you can think of it as a float of deepness into the surface. Read up on the other pages on the voxel gfx page and it goes into the details.
I'm currently working on the chunktree and the density. Chunk tree is almost there and I have a working density but needs refinement.
To do dual contoring and surface nets We will need to swap to a density model (because of the gradient requirement).
The current binary model is a subset of a density model.
I think the way forward might be more breaking changes so that we work in density with the binary model being a special case of the density.
So I have been having fun with the chunktree with LODs and this is how it is currently looking:
https://user-images.githubusercontent.com/13386481/120269646-65b1bd80-c2d2-11eb-9557-371652707056.mp4](https://user-images.githubusercontent.com/13386481/120269646-65b1bd80-c2d2-11eb-9557-371652707056.mp4
Check out my LODTree branch to see the code https://github.com/QuantumEntangledAndy/gaiku/tree/LODTree
I have been trying to work up some density based changes. I'd like to do it in such a way that we can reuse the same density code for the discrete (u8) case too.
What I would like is for the density to work like this.
- Given a density map that fills the space a to b
- Bake an arbitrary sub range c-d provide a-b contains c-d
- At an arbitrary number of interpolated grid spaces using interpolation
This will make the code for the LOD tree simplier and allow large structures to break up easily into smaller chunks.
The interpolation should also smooth the structure a bit.
I am debating how to specify the sub range c-d should that be in the BakerOption and how the a-b domain could be specified maybe in a trait for the chunk. Only we have a lot of seperate traits now and it would add another trait bound to the Baker one that is not always needed which I think rust won't allow. So maybe a seperate function in the baker. Maybe bake_range. I am starting to feel like there are too many traits to maintain 555.