Recently i needed a way to seperate usable items from other objects at the scene. Like used at many games i believe the best way is using outlines.
I did followed some tutorials but none of them was perfect for my needs.
One really good material was from the Unreal’s Example Content Maps (M_Highlight). It has really clean lines and it uses Custom Stencil Texture which i need because i want only certain objects to get outlined. But it has a one major issue.
Because it is using Custom Stencil value every object using the same stencil value is merged together at final image.
Second material i found at an old Unreal forum post shared by user mAlkAv!An . It is using a Custom Depth texture but issue of this it doesn’t draw clean outlines around objects it’s also outlines insides too but it’s good because you can seperate objects from each other using a distance treshold.
So answer was a really easy, merge two materials together. Seperate objects from each other with a treshold and mask the outlines inside the object and combine with Custom Stencil outline and fill the holes caused by the merging of same stencil valued objects.
Here is the final material. It has some minor issues but it does the job. You can get it from this Pastebin link.