Make Outline material fade/hide with distance

Greetings,

I’m using a simple outline material within my PostProcess Blendables to make a custom hover/non hover effects over all props I need. Sometimes, on a big distances this looks ugly because this effect scales up with distance. So I’m interested in fading/hiding this effect from a player camera over 1000 meters or more. Is it possible to achieve and how it possible if so?

Thank you.

Would love to figure this out also.

Figured it out.

Duplicate your outline script. Add a new Lerp node and plug it into emissive. Plug The original outline script into Lerp A. Plug the duplicate outline into Lerp B. Add the script in the image to the Alpha. Mess with the Divide and Power constant to determine the best fade from first person camera for your situation. Mine is 250000 Divide, .5 Power. On the Duplicate script (plugged into B) in my case, I just turned the parameters to 0 (line width, bloom, etc.) which effectively shuts the outline off, so it fades from the original outline to no outline in the distance. If you want to, you can compound this script and have it fade in layers, for example, near outlines could be blue, then they fade to yellow in the distance and then fade out completely far away. This fade script is similar to how I fade ground textures out in the distance.

You can also just unplug the view size node at the beginning of the script and the line will get thinner as the object gets farther away, but it will never fully disappear and objects far in the distance will be a clump of black lines (if you are using black as an outline). If you want to have it fade nicely to no outline at all, just plug in the regular scenetexture node into B instead of the duplicate script. I added this script to completely fade out and shut the outline off at distance however because it looks better in my scene when really far away objects do not have a black outline and the performance is much better (I’m using this as a black outline for a stylized graphic art look to all the assets in my game world with a very subtle thin line around objects in relatively close proximity, but leaving the background looking painted which is a common style in old cartoons and comics where only the objects in the foreground have a black outline. I needed the fade, because it is an open world and you can walk to objects that you see in the distance and the outline gradually fades in as you approach closer to the objects, everything from rocks to pickup items to trees)

Thank you :slight_smile: