I’m new to the forums and this is my first post!
I’ve been working with SDF’s and SDF primitives (think shadertoy) recently and figured I would try and use them for a university project I’m working on. My question is, has anyone done anything like this before? If yes, I’d love to hear how you approached it? So far I’ve been unable to find almost anything related to this as most of the SDF usage revolves around shadows and AO.
I did quickly prototype this by creating a custom pixel shader following the custom shader creation ideas discussed in https://forums.unrealengine.com/showthread.php?58489-Tutorial-Pixel-and-Compute-Shaders-in-UE4. As for the pixel shader it is pretty standard when it comes to raymarching SDF primitives. The output is written to a render target and for now I’m using the alpha channel to store the depth of the trace for culling later. As for displaying the result in the scene I created a post process material where I compare the depth value to the Scene Depth.
At the moment the solution still has many problems and it doesn’t take into account any of the lights in the scene nor does it generate any shadows whatsoever. Also for now there are no interaction between the object and the rest of the scene but I’m planning on approximating the shape with simple collision shapes as the size of the object is not random but can be estimated. One problem I noticed as well with this prototype is that there’s something wrong with the depth estimation when rendering the post process material as you can see a thick outline of the object when looking against the sky as seen below
All in all there’s still a lot to do but would love to hear your opinions and suggestions.
A small video of the prototype:
I added walls to the scene to “rid” the scene of the black outlines
The rendered SDF scene is a slightly modified version of https://www.shadertoy.com/view/MtSGRt so all glory of that to the creator.
Sorry for the short post, I wanted to write something up quickly before heading from the University. I’d be happy to answer any questions that you might have and will try and keep this post updated as I make progress. Also forgive me if my terminology is off somewhere, feel free to correct the mistakes