Node material to hide backfaces and interior faces on transparent object?

I have been working with node materials and renderlayers to learn a little. I would like to achieve an effect very similar to the “Normal Node Example” in except that the backfaces and the interior faces would be hidden.

(In the example from the manual we wouldn’t know if the ginger guy was pregnant. The interior faces are the little guy inside.)

I got some OK results with renderlayers but the shadows were not correct. Working on a material instead of a render effect I tried to add complexity to the example in the manual:

My idea was to to add a ramp material that had “energy” as input so the interior faces would be null to it. Then to mix the energy value with the sample from the manual using a minimum mix node. Of course this didn’t work for backfaces.

I think am really looking for a node setup that will tell me how many times a ray from the camera viewpoint intersects the geometry before reaching the face then only render faces that have the value 1?