I've been working (as so many others before me have) on a small Voxel-type game prototype.
So far, i have a 3d array (16 by 16 by 255 elements) that contains block ids - and as of right now, 0 means "no block"/"air", and "1" means "block".
For the purposes of isosurface extraction (for use with e.g. Marching Cubes), i now want to convert this format to a distance field - but i am having a hard time understanding how to do this.
Can anyone give a short explanation or point me in the right direction?
\$\begingroup\$
\$\endgroup\$
3
-
\$\begingroup\$ You can run marching cubes directly on your 0/1 voxel representation if you need. Is there a reason you want to convert to distance fields first? (eg. to inflate/deflate the isosurface away from the midpoint between 0 and 1) \$\endgroup\$– DMGregory ♦Commented Sep 4, 2019 at 20:42
-
\$\begingroup\$ Frankly, the implementation of marching cubes im am using requires a distance field as input. \$\endgroup\$– tubberdCommented Sep 4, 2019 at 20:43
-
\$\begingroup\$ Fine, treat no block as a distance of 0.5 and block as a distance of -0.5, now you have a distance field that's valid in the interface between blocks and not-blocks, and you can find any intermediate values in that margin using LERPs. Do you need something this direct reinterpretation doesn't furnish? \$\endgroup\$– DMGregory ♦Commented Sep 4, 2019 at 20:46
Add a comment
|