Cycles: How can the camera position be removed from the Light Path node's Ray Length
If you think about it, it's pretty easy; The way Booleans (true or false, not the modifier) are represented inside Blender by either 1 or 0; So if you do "1 - is Camera Ray", you will get ,basically, is NOT Camera Ray; if you multiply the Ray Length with is Not Camera Ray you will get the length for all rays except for the Camera ones. You could choose another Ray, and multiply it with Ray Length, to basicly get the length of that Ray.

Also note there's a Ambient Occlusion node.



After the part inside the box, you can use the rest of your material.