Material Edge Fade

Hey there guys, im not an artist by no means and im wondering if the following effect shown in the image below can be achieved easily?

I want a material that i can place on a cube for example and when any other geometry overlaps it, it fades over black.

If anyone understands what im asking, can you point me in the right direction as to how to achieve it, or even better, show me a working example haha.

Thanks guys.

Try playing around with DepthFade node. Plug it into opacity and adjust FadeDistance with a scalar parameter. Not sure if that’s exactly what you need, but may work :slight_smile:

Yes thats a similar effect to what i want, however is it possible to make it go the other way, instead of fading back onto itself, can you make it fade over the top of the other geometry?

I think you should be able to do it the other way by just putting the fade distance material on the other geometry you want to affect.

That wouldn’t really be feasible. What happens if i want it to affect all geometry?

If you want to affect all geometry, I guess you’d make their materials in the same way, so they also react to being close to other objects. If you make all the materials instances of the original, you can switch on and off the function with a simple blueprint that controls a material property dynamically, so that every object with any of those materials are affected simultaneously.

Can the material for this ‘cube’ be translucent? If so the effect is pretty easy. You want a custom version of depth fade that is biased in front of the surface rather than behind. It’s actually super easy to compute.

clamp((PixelDepth - DestDepth) / depthscale)

Where depth scale is the number of world units for your gradient. Then you need to goto the material properties and set “disable depth test” and use the above node as the opacity. Then you need to perform your darkening using a gradient similar to above and use a SceneTexture sample to fake the darkening. that will also probably require a reversed gradient to fade out the darkening effect before it gets to the cube’s depth.

Thanks for the reply.

Yes it can be translucent.

I might have to do a little research into how to build materials, im not very familiar with the Material editor beyond making simple single color Materials.

If its easy to put together could you screenshot the solution, if not ill work it out.