godot_sdf_blender icon indicating copy to clipboard operation
godot_sdf_blender copied to clipboard

SDF Mesh Support

Open SIsilicon opened this issue 3 years ago • 1 comments

The proposal's simple. Add an SDF node that represents a mesh. Now, obviously, this would be a difficult task to achieve. You would need to generate some sort of structure to store the triangles efficiently, like BVH. Then it would need to be uploaded into an image and traversed in the shader. Fortunately, I have experience in BVH construction and tracing, so whenever I can, I could implement it. :)

SIsilicon avatar Mar 01 '21 05:03 SIsilicon

I'm not planning to work again on this plugin soon, but in my voxel engine I implemented a VoxelMeshSDF which generates accurate SDF "islands" near triangles, and then "propagate" them using a floodfill algorithm to quickly approximate the overall SDF of meshes. I determine signs using several raycasts. It could be made even faster by using a variant of Jump Flood in a compute shader.

Another challenge is the fact raymarching the mesh's SDF grid using trilinear interpolation results in aliasing. tricubic interpolation sounds like a nightmare. Instead I saw it coud be improved by storing gradients in the grid using normals of the mesh, and using hermite interpolation.

MGilleronFJ avatar Mar 06 '23 17:03 MGilleronFJ