raytk
raytk copied to clipboard
SOP-based SDF
Why this is hard: "Geometry" in RayTK is defined using SDFs which are mathematical functions that find the distance to the closest part of shape from any point in space. Regular SOP geometry is defined by a collection of triangles that are connected to form surfaces.
To determine how far a point is from a surface defined by a mesh is a complex problem. There is some research around doing it with machine learning. The bunnySdf is based on a shader created using that process.
Options: Houdini is able to do this sort of conversion from a mesh to a grid of points with distance values, but it definitely is not a realtime operation.
There's an example of a possible voxel-based implementation here using a 3-pass rendered that gets a distance map for each axis. https://github.com/DBraun/TouchDesigner_Shared/tree/master/Starters/boids
Both of these approaches only work when you limit the space to a specific grid of points. Using that for an arbitrarily positioned SDF has limitations.
An attempted adaptation of DBraun's approach is in progress but needs a lot more work.
Other potential approaches:
- Unity approach: https://github.com/aman-tiwari/MeshToSDF/
- It also may now be built into Unity: https://docs.unity3d.com/Packages/[email protected]/manual/sdf-bake-tool.html
- Neural network approach: https://youtu.be/8pwXpfi-0bU