Hello past human!
Hope it’s helpful to someone.
Very very much so! Exactly what I was looking for. Thank you so much for the detailed write-up.
What did catch me off-guard and was a couple hours of debugging was this almost throw-away line in Tom Looman’s post:
Custom Stencil is disabled by default, to enable go to Window > Project Settings > Rendering > Post Process > Custom Depth-stencil Pass and set it to Enabled with Stencil.
Don’t forget that! Even if your Custom Depth is Enabled, you need to set it to Enabled with Stencil!! Crucial difference!!
One more thing I did differently: when I followed your tutorial to the letter, I noticed it was my character mesh that got coloured in the UI colour, indicating that the stencil was doing the exact opposite of what I wanted; I changed around which object I gave which stencil (i.e. your tut says to give the character #2 and the UI something else, eg. #3; but I did #2 for the UI and #3 for the character). Works a charm!
Might’ve misunderstood what you meant and just made a fool of myself, but if it helps a future human…!
Furthermore, in UE 4.25.3, I was able to use the ‘Default’ instead of the 255 bits option you mention at the end, but also not super sure what you meant with ‘sorting’ so maybe I’ll run into that problem later down the line and return here to correct myself. x)
P.S.
Some references for you friendly folks:
Get custom shaders (‘/Project/Shaders’ “folder”) in Material Editor to work again in 4.25.3:
Tom Looman’s post on Custom Depth:
(Note that the ‘PP Volume > Settings > Blendables’ instruction he mentions is most likely now the PP Material part of the PP Details panel, i.e. where you assign your PP Materials; Blendables is old nomenclature I guess!)