Download

How can I use Distance Field in shader without applying DFAO on a single object?

Hi,guys.I’ve got a problem while I’m making a local volumetric fog box.Here’s the detail.

Let’s say I want to create a local volume by VOLUME material domain,and it’s requested to capture the static mesh shape border so that I can make the volume look like the inside shape of that mesh.

But the only way to get the shape of mesh border in 3D space I can think of now is to use the Distance Field,but the DFAO coming with the DF enabled is really depressing and unacceptable.

Is there any way to Enable DF without Applying DFAO just on a single mesh which i assign this volume shader so that the scene’s DFAO still remains? Or any other method to get the shape border of a static mesh instead of DF?

Anyone could help me out?Please, thanks in advance.

I have to be honest I don’t quite understand what you’re trying to do with the distance field here.

If you need a distance field for something as simple as a box (or similarly simple shape) the best way to do this is to define the distance field in your material using a signed distance function rather than relying on sampling the global distance field. As usual, Inigo Quilez has already written a box function that you can port.

For more complex geometry your best option in my opinion is to write the distance field to a volume texture and sample it. There are a few ways to do this but if you have access to Houdini, that’s what most people seem to use.

And to make my question clear ,I just want to use the distance filed to compute a nice fade effect on any custom geometry rather than simple box or sphere and the following pictures are my shader network.

As the DF is requried in shader,the DFAO on the enviromrnt enables as well,which is not waht I want.

Problem Solved! :grinning:
Instead of sampling DF in shader ,I convert custom geometry to Volume Texture in Houdini and sample it in shader ,and the result is almost the same .
Thank you for your advice again! :kissing_smiling_eyes:

1 Like