World Normal Edge Detection ( and Speedpaint Art Style)

Ok, so i have some problems i can not solve myself. The first question is, how can i calculate sorting ? The main problem is that the pixel offsetting happens due to overlapping actors in depth. The postprocessing simply can not know which pixel has which depth. I tried to subdivide scene depth into 8 pieces to separate Meshes against each other. But that did´t solve the issue. Ambient occlusion seems to have some sort of “depthcheck” between two objects. While you don´t want it there ( black shadowing behind object) it could solve the flaming breakout issue on my material.

The second question is how Bokeh dof is filtered.

be2b4fb3892ec67bc443c9f9794862ed9b9ad0fb.jpeg