Download

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.

cf7ea64d0184722c4dab38b7faf432102e672028.jpeg
97a35035a4178a05bd1e8088c8ada2d7b57fe198.jpeg

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:
occ.png

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:

921ac483879775eb9bcfc7a81021440018eb9510.png

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:
83e8d3336a16d680479fe13297fe2ef5c5ed0046.png

And it comes out just like this:
Screenshot (2).jpg

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?