How to color outlines by objects material color

Hey guys so I followed this tutorial HERE to create an outline shader and with this one you can choose to draw outlines on just the inside or outside edges of an object. This is useful because im trying to take the lines drawn on the inside of objects and set its color to the diffuse color but just darker so i have colored outlines based on whatever color the object is.

Like this


In the first image the objects have just one material and i have a cel shader that just separates the shadows to be slightly darker. With my outline shader the outlines are colored with the diffuse color just much darker.

The second image the object has multiple materials for different parts of its mesh and doing the cel shader and outline shader makes the outlines different colors based on the materials diffuse color.

This works well for the look i want but circled in blue are spots where the outside lines of closer objects are still being drawn just not colored and it creates breaks in the outlines.
Does anyone know another method to achieve this colored outline effect or maybe a fix for detecting inside edges better? Ive been pulling my hair out trying to remedy this so any help is greatly appreciated. Thx