mgumley wrote:
Do you know of a way to get the partial voxel values for an input mesh that is not cubic?
I think the easiest approach would be to create a binary (cubic) volume at higher resolution than you need, and then downsample it to a smooth volume of the requred resolution. So if you wanted a smooth volume of 256^3 resolution, you might create a binary volume at 1024^3 resolution and voxelise into that. Then groups of 4^3 = 64 voxels would be summed up to give a value between 0-63, scaled to the range 0-255, and written to you smooth volume. Obviously there are performance and memory implications to this approach, which my or may not matter to you.
Alternatively, a smarter approach would be to test not only whether a voxel is inside a mesh, but also
how far inside it is. If a triangle slices a voxel in two then determine what percentage of the voxel is inside. This then tells you what your density value should be. This method is probably faster and more scalable but requires more maths and thought.
In general I would research
antialiasingtechniques (e.g.
this one), as I think what you are describing is basically the 3D equivalent of those.