I did one thing, I multiplied the scene depth by a parameter and used it as a cutoff value to be compared against the sum of scene depth differences which draw the lines. This means that if something isn’t far enough away from the thing behind it then it won’t draw the outline.
This works pretty well but still gives a good amount of detail in a lot of things. Also when you are very close to something the outlines don’t show up as much as desired. It is a pretty good compromise though.