2 nodes i need in Cycles: AO as input and "Thickness" without transparency

In order to manipulate the “live” (not baked) AO information in the material nodes, it needs to be an input; having it as a shader limits the possibilities too much.

And i also need a way to get somthing like the “brightness”/“shadows” from an x-ray but as an input, without the object actually being transparent. Basicly the thickness of the object along the viewing axis, or the distance to the first face or backface behind the face in question along the ray.

I don’t see any builtin material node on Cycles that does either of those things; does any of you got any clues how i can get such behaviors in Cycles without having to learn how to program shaders myself? (obviously noddling is alright though, and so is using plugins and ready-made OSL shaders and things like that if it does what i need)

ps: In case you wanna know, i want this to make cartoon style outlines in Cycles with more individualized control than would be possible by using compositing tricks (at least with the same amount of effort)

pps: also, if you can think of a way to get the AO values for the backface of the face as input, please let me know, it would also come quite in handy for details that would otherwise go untraced when viewed from certain angles