maheshvele wrote:
Could you please help me understand this? I am using the following code....
It's quite hard for me to explain this to be honest, I think you will need to study density functions in general. But the idea is that densities can have a range between 0 and 255 (at least in our case), and that if a density has a range < 127 then it is considered empty, otherwise it is considered solid.
The following code will give a very jagged mesh because all the densities are either 0 or 255:
Code:
uint8_t uDensity = 0;
//If the current voxel is less than 'radius' units from the center then we make it solid.
if(fDistToCenter <= fRadius)
{
//Our new voxel value
uDensity = 255;
}
To make it smooth you need to ensure that your voxel values have a gentle transition from low density to high density, and one way to do this is to use the distance directly (the distance changes gradually and smoothly). But the distance goes from zero to infinity, and you need to map that to the range 255 to 0 (our sphere should be solid near the origin and empty further out). In the code you showed, the multiplications and additions basically perform this mapping.
maheshvele wrote:
if I change the value I multiply the density with, I do get seemingly smooth surfaces but then, I also get a lot of thickness with the mesh(which I don't need).
Yes, imagine you have a voxel with density 20. The sphere does not include this voxel (as the density is less than 127), but if you multiply all voxel densities by 10 then the new density is 200 and so the sphere does include it (as it is now more than 127).
maheshvele wrote:
Does cubiquity use the low pass filter internally?
This stuff is actually separate from what PolyVox and Cubiquity provide. Both libraries allow you to turn a density field into a mesh, but in both cases the issue of generating the density field is left to the user. The user can use noise functions, implicit surfaces, or (in the case of Cubiquity) use built in sculpting tools to set the voxel values.
So Cubiquity does use low pass filtering (I forget if it uses the PolyVox code) but not for the purpose of generating the volume data as this task is not performed by Cubiquity. I think it only uses it for LOD generation.