Previously, I found an useful article that explained how to convert 3d mesh to SDF easily.
I want our artists to be able to easily convert from polygonal data to SDFs with little-to-no effort.
this article is what I want but unfortunately there wasn't simple Implemention.
there is algorithm in this article:
foreach (pixel in texture) foreach (triangle in mesh) get pixel center as mesh bounds position get closest point on triangle calculate distance from pixel position to triangle keep the smallest distance perform a raycast along arbitrary vector against triangle if(raycast intersects triangle) increment an intersection counter if(number of intersections is even) pixel value is positive // outside mesh else pixel value is negative // inside mesh
I like to Implement this article but I can't understand above algorithm and I don't know how can I convert 3D mesh to SDF data and then sotre this data to 3D RenderTexture?