Okay then. Not sure if this will help anyone else, because I’m not even sure yet if it helps me. But, I made a fluke discovery that seems to work in my particular use case.
If you take a look at the post-process Material that is being created for the Widget, where you mask out the CustomDepth stencil of your Mesh from the UI’s opacity, you notice the constant ‘1’ that is being passed into the bitmask? If you change that constant, and set the Custom Depth Stencil of your mesh to that number (i.e. constant set to 2, and CDS of Mesh set to 2 also), then your Mesh will draw over the UI, even when the UI is occluding other Meshes (and even if they are using Custom Depth).
Note that in this case, I have removed the Post Process Material from my PP Volume entirely! I’m not running a PP Material on my Mesh anymore; I’m only using the CustomDepth attribute on that Mesh, and only running a CD Mat on the UI element.
And here’s the result:
Let’s analyse this picture:
- The UI renders over objects in the background
- The UI renders over objects in the foreground; in this case, that object is even using a Custom Depth itself (Tom Looman’s, to be precise)
- The Hand renders over top of the UI object, as is the intended effect.
- [Not shown]: The Hand does not get shown rendered ‘behind’ occluding objects, unlike with my previously described approach.
What is interesting here, is that when I switch back to my translucent Material, it also masks the UI as if it was an opaque Material. It isn’t quite what I expected, but it does make sense when I think about exactly what I programmed in.
I’ll do one more pass of experimentation to see if I can combine the two effects: proper occlusion like with the opaque Hand, but using a transparent Material for my mesh.