I’m trying to set the voxel type on an isosurface material, and I’ve been a little stuck for the past few days on how to best go about solving it.
I’m using an array of integers to specify the voxel type (which i then pass to the geometry). The voxel array is the same size as the isosurface DensityVolume array as seen in the isosurface demo @pspeed wrote. Basically this:
float densityArray; // size 19x19x19 int voxelArray; // same size as the density array - dictates what material to visualize.
So when I modify the density value in the densityArray, I also modify the same index in the voxelArray.
At first I use a noise-backed biome generator to define initial voxel material values (grass, sand, dirt, etc). This works fine. I then use what I call a brush to modify the terrain - as shown in the video below. The brush modifies the terrain fine. When it does this, I also modify the voxel types too. So if I modify index 12 on the densityArray, I modify index 12 on the voxelArray too. It works in theory, but I get a wierd bleeding issue on the negative side of all axis (left, bottom and back).
I know that the point of a voxel (it’s definition) should be at the center of the voxel, not the edge, and I’ve tried offsetting the values by 0.5f to cater for this but it doesn’t seem to make any difference. The negative sides are still set to the voxel they were - as if unchanged - and even more annoyingly - the intersection between them is always grass - like some kind of wierd interpolation that I can’t get my head around.
Can anyone give me a hint in the right direction?