Im trying to implement smooth voxel grid meshing using marching cubes algorithm but I dont quite understand how to do the interpolating (I understand that this would solve the problem) to achieve the smooth transitions on the borders between the empty space and filled space.

enter image description here

In the picture above I have rendered my voxel grid cells as cubes. Currently the voxel grid is just a 3d array which stores the values if the cell is empty (0.0) or filled(1.0) (not sure if this is ok, do I need to store each cell corners instead).

When processing marching cubes iteration I have to sample my data at floating point indices e.g. I need to look up if position (3.316, 0.16, 0.5) is empty space / on the surface of the data / inside the data.

Currently I just check the cell value where the position is e.g. (3, 0, 0) for the example above which results with cube mesh.

This shows what I want to do more or less: enter image description here

  • \$\begingroup\$ Let's say you have 2 vertex with 0.3 and 0.5 as value. Of course the vertex would get closer to the 0.5 one, because it's higher and it's more in the model, \$\endgroup\$ – Bálint Apr 17 '16 at 16:03

I got something working more or less using trilinear interpolation (Wiki).

When the marching cubes vertex is sampled, I look for the neighbouring data in my voxel data, use this data for interpolation described in wiki.

Example: in(3.14, 0.4, 1)

x0 = 3, x1 = 4

y0 = 0, y1 = 1

z0 = 1, z1 = 2

which are used directly in wiki algorithm.

Heres an example of the output I got enter image description here

  • \$\begingroup\$ Please, mark this as the answer \$\endgroup\$ – Bálint Nov 22 '16 at 6:32

The voxel map doesnt contain enough date to go back to the perfect spherical mesh in the image. I have seen a page, searching for voxel spheres, where a guy creates a mesh by expanding outwards from the sphere and averageing it, but his methods arent shown on the page: https://www.cgl.ucsf.edu/chimera/data/falloff-sep2012/falloff.html

The most round antialias you can get from your graph is by keeping only the voxel corners and edges and throwing out all the flat voxel faces. that afterwards gives you kind of a point cloud which can only have the corners of the sphere and not the flat staircase bits, which encourages a better sphere. you cant interpolate backwards from voxel to round shapes very easily, and i think that antialiasing the voxel space is best done by throuwing out all the face voxels and the inner voxels and using only the edge and corner voxels as points of a new sphere/shape. if you can find a poisson disk library for your project, use the described points to make a new sphere, it will be ok. afterwards, to antialias further, all voxels that are not under a higher voxel pointing towards it should also be taken away, i.e. some of the staircases are also made of corner voxels where some of them are above others in flat strata.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.