SDFs to Dynamic Meshes

addyhush1
Fri, 11 Apr 2025 16:16:56 +0000
Programming & Scripting

Hi there computer graphics programmers!

My goal is to translate moving SDF shapes into dynamic meshes in runtime. I know, runtime mesh generation is not precisely lightweight but I see a lot of potential in the realtim-art space. I have different approaches and am trying to figure out what parts would need to be puzzled together and wonder how much I need to reinvent the wheel or if I’m missing something.

The reason why I want dynamic meshes instead of SDFs is the visual fidelity of lumen in combination with the smooth shapes that can be generated through SDFs. To be honest, if geometry scripting would allow mesh boolean operations like smooth min/max, it would solve it and I wouldn’t see the need for SDFs at all.

Why not just use the vertex shader like using distance fields (DistanceToNearestSurface) for the WorldPositionOffset? The results, even with sufficient polygons, do not resemble the smooth morphing, as it’s eventually still seperate meshes that also cause z-fighting.

Defining the SDF Shapes

is easily done in custom HLSL nodes in the material graph.
I’am aware of:

the limitiations with to functions

using multiple custom nodes and piping them together as a CustomExpression

writing C++ code into custom nodes to create functions

compiling my own nodes
However, I face difficulties extracting the “fake” spacial data from the material framework in a reasonable way and see now that I might need to implement the SDFs through compute shaders.

Generating Dynamic Meshes

This is where I’m the most unsure. There is the geometry scripting framework and the procedural mesh generation but I havn’t found much about how to generate shapes from other spacial data. Maybe I was missing something?

PCG seems like a promisiong framework for this. I can totally see that I use the HSLS implementation to generate the SDFs and output the points that then could be used as poligons to generate meshes through the PCG geometry scripting interop. I even think that normals could be calculated in hlsl and forwarded for the mesh generation as an attribute. But I’m not sure how much PCG utilizes the GPU and whether it would turn out to be a slow solution.
I haven’t seen much about PCG mesh generation out of points except by Yazan Hanna. I know, this is quite fresh but are there more resources out there about this?
Would the solution here be to write my own custom geometry script node through C++

I’m open for any branistorming and referencial thoughts. I think this could be a quite interesting discussion and there is no immediate pressure to find the one and only true solution immediatelty. I’m quite interested how much I can use the existing frameworks in UE or if it’s better to write everything from scratch. Thanks in advance for your input!

1 post - 1 participant