Outline Post Process with occlusion

Hello,

I’ve gotten the post process material from

But this material shows the outlines of an object even when behind other objects. How can I occlude the outline so it won’t show up behind other objects?

Here are some screenshots to make it more clear of what I’m asking.


Thanks
Z

you need to check if the scene depth is closer (aka smaller) than the custom depth, minus some threshold to avoid self hitting the chair that has it.

you can just use an IF node. scene color + scalar (for bias)goes into A and custom depth goes into B. Then for the >= I think you return 1 and for the < you return 0. And of course don’t forget to play with the bias. try adding like 0.1 or so at first.

I tried it, but it had no effect whatsoever. Maybe I’m doing something wrong?
Here is a screenshot:

hmm did you try outputting just the result of that IF mask? That looks about right but there are some different versions of SceneDepth that are unclear. What if you try to use the one that is simply “Scene Depth” withhout the “SceneTextue:” prefix.

When I output the result of the IF mask, everything goes black. I also tried using just the Scene Depth, but it had no effect. I think that the problem might lie in the other nodes of the graph.

If you plug in just the IF nothing else should be affecting it. I would focus on just the mask when debugging. I am not sure what is wrong but I will take look soon.

If you could look into it, I’d be very grateful.

works fine here using “Scene Depth” node:

Did you try playing with the addition threshold like I suggested? Even if you hooked it up backwards it should still work (just inverted white/black) if you indeed tried making it go negative. did you make it a scalar and try various values like I mentioned?

edit actually I just set up my example exactly like you had it set up and its working fine here.

try it in a new material. make sure its a post process type and applied as a blendable if not. Also probably a silly suggestion since you already had the lines working but also make sure custom depth rendering is enabled in project settings.

I solved it by doing it this way:

And it comes out just like this:

Ok. Should be exactly the same as hooking 0 and 1 to the IF and then multiplying by that.

Ah, my bad. You’re right. I was looking at your setup backwards. Now that I check again I was putting the 0 and 1 in the wrong spots and it came out solid black like numsi said. From his screenshot, looks like that’s what he did too.

Thanks, Ryan the material I had was not working, so I created a new material and that seemed to fix the issue.

Great thread, helped me a lot with my outlines. Now, what if both chairs had their CustomDepth enabled? With the solution above, the outlines of the chairs are merged together. Is it possible to ‘close’ the outlines on the front chair like in the picture below?