This shader will be able to:
- Change the outline thickness
- Change the colour of all outline
- Change the colour of specific actors outline
- Apply on specific actors (Custom Depth Mask)
- Control thickness based on distance (Distance Masking)
- Limit grazing artefact (Line too thick when camera is against object)
This outline shader is a PostProcess effect that will analyse what is shown on the screen, detect edges, and draw outlines.
We will use Depth Edge Detection obfuscating edge outlines, and Normal Edge Detection for sharp edges.
NOTE: I will re-write this in future and replace images with blueprintUE embeds.
Apply Post Process to the Scene
- Make a PP_OutlineShader material, preferably in /PostProcessing
- Set the Material Domain to Post Processing
- Set the Blendable Location to Before Tonemapping
- Right Click on PP_OutlineShader, and Create Material Instance, call it PPI_OutlineShader
- Add a PostProcessVolume to the level.
- Add a Post Process Material to the PostProcessVolume, and set it to the PPI_OutlineShader
- Add a SceneTexture:PostProcessInput0 node, and plug it into the outputs Emission
MF_GetKernal (Convolution Kernel)
- Create folder PostProcess/Functions
- Right Click > Materials > Material Function
- Create MF_GetKernal
- In MF_GetKernal, copy/paste the output 4 times
- Name them Left, Right, Up, Down
- Set the Sort Priority of each one to 1,2,3,4 respectively
- Create a FunctionInput node, call it Width, and change it’s input type to Scalar
- Create a Constant of 1, and plug it into the Input node
- And then:

MF_DetectEdges_Depth
Create another Material Function

How to use MF_DetectEdges_Depth in the PP_OutlineShader
REMINDER: We must add the PPI Material Instance to the PostProcess Volume.

Gameplay

Grazing problem (outlines at steep angles) we will fix later.

MF_DetectEdges_Normal
- The Distance nodes are Utility>Distance
- Input Threshold of 1, we don’t need inside or outside edges, as the MF_DetectEdges_Depth function does that already.

How to use MF_DetectEdges_Normal in the PP_OutlineShader

Notice the light internal lines at sharp angles

MF_DTM_GrazingAngle (Grazing Artefact Fix)
- DTM = Depth Threshold Modulation
- We can use a Fresnel node to detect normals that are near perpendicular to the view

How to use MF_DTM_GrazingAngle in the PP_OutlineShader

MF_ThicknessModulation
- Make far away lines thinner
- the inputs are FunctionInput nodes
