Hi, I want to implement occlusion hightlight using materials. When my character is occluded by some objects it can still emit some color rather than being totally invisible. Here is my material blueprint:
where I use an infinite post process volume and set my character’s Render CustomDepth Pass to true.
Now everyhing works fine. But the problem is: anything that blocks my character will make an effect on the custom depth, but I really want some controllability over the objects with which I can determine some will make my character become transparent while others won’t.
For example in the following two figures, the first cube occludes the character but it does not make any effect to the transparency but the second one, if I specify, will make an effect.
Hi, thanks for your reply. I tried custom depth stencil but it did not work in my case because i still cannot determine the occlusion relationship between the occluder and my character.
That being said, if i set the stencil value of the occluder to 1 and that of my character to 64, then the custom depth buffer will store a value of 65 at the pixel of occlusion but no more information about which one is at front. In this case, even if my character is in front of the occluder (closer to camera), the character will still become transparent.
Just loosely thinking here but if you run a line/sphere/whatever trace on/around your character, can you get the things found and update values in their respective material-instances?
Maybe update an MPC that materials can centrally-reference?
Writing your own shader might be a possibility. It seems that, mechanically, you’d want to use a bitmask AND depth and I don’t know how to get both of those via a material/shader.
The trace might help you sort depth, but no idea how performant it might be on top of everything else. If you are already doing some kind of trace (like for lockons) maybe piggy-back?
1.) Select your actor → Details Panel → Actor → Advanced → Tags (+)
2.) Add a Tags Array Element by clicking the (+) sign
3.) Type in a name for your Tag, such as “Occluder” (or whatever you want to call it)
4.) In Blueprint, add the node “Get All Actors of Class with Tag”
On the node, be sure to use the “Actor Class” drop down to select the class you want to match.
Also, on the “Tag” input, be sure you type in the same exact tag name you used for the actor(s) you want to fetch.
From there you can, set the result as a variable, and fetch them using a For Each Loop on it to do whatever you need to do…such as setting Custom Depth on / off.