During the Unreal Engine 4 Beta I experimented with an object outline post-process that I’ve attempted before using Unreal Engine 3’s UDK, with limited success back then.
Update: For an updated multi-color implementation of this effect Click Here!
Below is the first version I had running during Beta. It’s built on the new “Custom Depth”-rendertarget that allows the engine to render marked objects to a secondary depth buffer. The post process samples this buffer and builds an outline when the difference between neighbouring pixels is large enough.
The left-most sphere is not drawn in the Main-renderpass (another checkbox available in the Details panel of a StaticMeshActor) the middle is using both Main-renderpass (default) and the CustomDepth-checkbox. The right is a default StaticMeshActor that is not drawn into the custom depth buffer, therefore not showing any outlines.
The second iteration alters the outline behavior slightly so that only the occluded parts of a mesh are outlined. (given that the object has custom depth enabled)
Overview of the Post process material. Not very readable unfortunately except for the comments, which give an idea of what is going on.
The next step is to add a fade-off effect as seen in games like Left 4 Dead. This requires some changes to the original sampling as the current outline is actually an inset. I’d also like to differiantiate between different types of objects, eg. enemies as red and friendlies as green – which would require a bit of trickery in the current setup. More details on that in an upcoming post…
Update: Download link added to an updated outline post process. For more info on the material check out the new blog post here!
Post Process material for outlines with translucent veil on occluded pixels.
After copying the .uasset files into the Content folder of your project you must add a Post Process Volume into your scene and enable the Unbound property, also don’t forget to add the post effect material under Blendables.