How to create outline material with forward shading?

Good evening. I’m trying to switch from deffered to forwatd shading and it looks like there are a problems with post process shaders. I’m trying to re-create outline shader. I found 2 ways to achieve that:

  1. https://www.youtube.com/watch?v=Ptuw9mxekh0 the guy is getting cool effect like this

    but for me it’s looking like this:

    and error
    "GPU Crashed or D3D Device Removed.
    Use -d3ddebug to enable the D3D debug device.
    Check log for GPU state information."
    so I don’t know how to make it look good and how to use it as mask to get only outlines



This material can give good result but all the lines can be seen through the walls

and it look much worse than original PP material I’ve used for outlines:

Is there a good way to achieve outline effect with forward shading or ways to improve materials I’ve mentioned?