I’ve been stuck on this since yesterday Im trying to make a “See through wall” Post Processing effect. Though it doesnt work if 2 meshes have Render CustomDepth pass.
Then only one stays enabled. The other further in the background gets disabled the moment you enable it for the other.
How do i allow the post processing on both meshes?
Project and video below:
T_DepthCustom.rar (2.0 MB)
Yes you can do that by using different stencil ID masks
2 Likes
Ahh, i had the feeling it was related to the custom Depth stencil write mask 
Though i thought this was much simpler.
Are you sure there isn’t a simpler way to do this?
So if we only have one “See through Wall” material, we can use just the standard 255 custom Depth stencil write mask. But if we need more than the others must use another Custom Depth stencil write mask, and the addition between the two must be linear interpolated.
This is quite complicated.
ill get back here soon. thanks.
1 Like
I followed the tutorial to a T, though it is not working.
This is still a bit of an obscure knowledge to me.
Only the overlapping should be yellow, whereas one of the cubes should be red, and the other green. Right?
Instead it seems one of the cubes is totally yellow.
Can you tell me what im doing wrong?
Project and video:
T_DepthCustom.rar (2.4 MB)
well it is simple actually once you do it as in many things you will see its just simple rather than complex.
I made it on my machine a simplified version to support you, hoping that it solves problem on your side.
*I have 2 objects with different stencil id 100 and 110
- I mask these and add a color on top then divide it since I will use opacity on them also don’t want something too intense.
- add them to each other also add on top of existing scene color. now I will just lerp between them depending there is a stencil on scene or not.
You can do many things on top of these ofcourse depending on artistic vision and what you need to achive since can be many things like enemy outlines, state changes, gameplay context changes etc.
Completixy generally comes from staying organised in complex shader passes and knowing your structure. Since there would be many artistic cool things staying organised generally creates sophistication.
PS make sure that in project setting this is set
1 Like
Thanks a lot. Im trying to remake it here.
It seems i dont have the function Stencil mask compare. Could you show me how is it inside?
Is it a UE5 only function?
Also does the red cube stay Red if it is in front of the wall?
Because thats not supposed to.
I made some tests here with my previous code and it was kind of working.
But then failed because the cube was red even when in front of the Blue wall.
ah yes ofc, it is basically and if statement on unreal engine 5 however same version in other nodes.
yes basically this will always highlight objects no matter what is infront of them
1 Like
You can always do other logic in many ways depending on what you trying to achive and what is it going to be used for. If I know I think maybe I can be more helpfull.
However if you need not to see behind walls (atleast for now) you can compare custom depth to scene depth to see if its behind an object that doesn’t have a stencil.
Here is
hope it helps, if so mark as resolved.
1 Like
I tried both solutions. Its still not working properly.
It seems the character is always painted red even when it is not below anything.
I changed the Custom Stencil Write Mask Values. Because it seemed to me you were using the Default values.
The character is supposed to be red only when it is below the cube (building).
But if the character is in front of the cube (building) then it should be its original material, PostProcessing 0, i think?
Everything im trying makes the character Red even when it is in front of the Cube.
Or the Cube cant have its own Stencil.
So basically what im trying to do is to allow the Cube to have a stencil value, and at the same time make the Character red color when it is after the cube.
Im sorry this is kind of confusing.
I send you the project with the Cube Sphere and Shadow plane.
I think we are getting really close.
The 3rd video shows the actual problem and almost the solution.
I only need to make the sphere not show as red when it is in front of the cube there.
T_DepthCustom.rar (8.7 MB)
Well I am not sure if I understood it correctly but its the same thing.
If you want something to be rendered just on plane on view then you have to check first if there is plane in between then you can compare again. There is a switch node too.
1 Like
Here is something similar to what you trying to achive, hope it helps you one step further.
1 Like
Thanks though it isn’t working well here. I might have missed something.
The cubes shouldnt paint blue but keep their original color. And only paint in a color when behind the wall. Then the shadow should only affect the cubes not the wall.
So basically we have 3 elements. The Spheres (characters), the Cubes (buildings), and the Shadow wall (fake shadow mask).
I made a graphic that shows exactly what im doing, and why it is failing.
It is working 99%, the only issue left to solve is how to make the sphere not paint red when it is in front of the cube:
Im sorry this is quite complicated, though i really need to make it work, because its for a 2D game that needs to fake shadows on top of Characters but never on top of Buildings:
Is this more clear?
So after checking again with fresh eyes, there is couple of ways to do this and there is multiple things you should consider first before going into a direction.
- Since you are using a stencil on your shadow: even if we don’t highlight it in front when player gets into view it would be visible. Since object is visible and you just stencil cube.
- That means you need another shader pass on top if you want to hide player behind shadow. So the cube is always visible.
- There is couple of ways to do that as well but it really depends on camera since if camera is always one angle etc can be easier.
- For the object highlighted red to be behind or front of another object problem has also answer but either workaround or engine modification: To explain the problem : when custom stencil is rendered is only have one depth pass which is same for all ids. That means all stencil have same depth. We can have more depth passes for objects on scene view being rendered for custom stencils, however as said needs engine modification. Then we can have a method to compare which is behind which is front.
- Also depending on the game you making we can workaround the problem by camera depth as well if its a 2.5d game.
- Please do check lightening channels (there is 3) where you can have multiple different light sources and shadows depending on what kind of a visual look and feel you need. Maybe you don’t need fake shadows to do the thing you need (just assuming)
Let me know if you want an engine modification.
After telling all these here is a ugly workaround you can use for your game.
-post process
-you material mask is almost same basically
-here is how it looks

This is not the correct way of doing things however it works nicely on my computer with different camera angles distances etc.
I can take a look at whats happening deep in stencils also interms of depth

1 Like
Thanks a lot. Will work on this one in the evening.
This has plenty of material for me to try.
thanks.