UE4 Outline Post process through the wall

Hi! Im making a anime style project for fun and learn this engine .
I made a Outline Post process by custom depth for only character like this

Outline Post process material

But there is a big problem. Outline keep display even behind wall

Make the building to custom depth can fix. But, in most anime background doesnt need outline. Only moving object do.

There are many ways to make outline, but this show the best result on character i think.
So is there any possible way to hide the outline behind object?
Thanks!

Use the Custom Stencil features to assign certain certain objects the post process material

1 Like

Check this post, this is how you solve it, you need to subtract the scenedepth from your customdepth, so the outline only shows when that pixel from the outline is not occluded by something else.
https://forums.unrealengine.com/t/how-to-hide-outline-post-process-effect-behind-objects/335022/3

In your material screenshot, you have 5 SceneTexture:CustomDepth nodes, the one in the middle, goes into 4 subtract nodes, always on the A node.
And then you have 4 SceneTexture:CustomDepth nodes that go into the B node of each subtract… You need to replace those 4 SceneTexture:CustomDepth for 4 SceneTexture:SceneDepth, just click on each, and on the left, change from custom depth to scene depth. that will solve your issue!