How to set occlusion in a Landscape?

Hi, im having some problems while trying to make a highlight material using CustomDepth on my objects. In some cases, behind other type of objects it works as I wish. As you see in the pic, the wall is set as an occluder and it stops from drawing the highlight lines.

But, somehow, while inside a landscape, part of the hidden object appears hightlighted. Any solutions?

Hello, firstly, in the top of your editor viewport you can click on the view mode (which is Lit by default), go to Buffer Visualization and select Custom Depth. That might help you to debug problems.

Regarding your question, as far as I know only components that have render custom depth set to true will be rendered into custom depth, anything else is invisible i.e. you can see through it. So you probably have to enable custom depth for anything you want to occlude the outline, and use the custom depth stencil to get a mask of only the object you want to highlight. I don’t know however what kind of performance impact it would have to enable custom depth for all components in the scene, you might want to test that and consider disabling it again while you don’t need the highlight effect.

I’ve tried making a mask for the landscape but I don’t know how is not working, It should change the color if I change it’s custom depth stencil and it doesn’t at all. Here is my material.

PD: Im only using the custom depth in objects only at the moment I’m looking at them, not all the time. Thanks for that consideration.

Also if needed here is the tutorial I’m following just to make the outline material from the custom depth.
[link text][5]

If I understand your material correctly, everything with a Stencil value of <= 2 will be drawn green, everything above pink. You probably want all occluders at stencil 0 and not rendered as an outline, then 1 for the first highlight color and 2 for the second for example. You could probably add a simple if node behind your color blending and check if CustomStencil <= 0 use the scene color otherwise use the result of the last color lerp node.