Cutaway shader with solid fill using stencil buffer

Trying to achieve this look [ATTACH=CONFIG]908[/ATTACH] using a cutaway shader with stencil buffer to fill in the clipped parts. The solid ground [ATTACH=CONFIG]907[/ATTACH] i use looks like this [ATTACH=CONFIG]906[/ATTACH] after clipping, notice the backfaces are also clipped. i don’t know how to apply the stencil solution discussed here https://www.opengl.org/discussion_boards/showthread.php/169569-cap-clipped-complex-geometry?p=1194165#post1194165. Can anyone explain me how to do it in this case?