You can access the ray length (Rl) via a state_float shader, which is the distance from the ray origin (camera) to the shading point.
I can't get it to work ... I don't get how to output a Z like render of my surface with a black and white gradient ... Any tip ?
I plug the output of the RL into a ramp_float node, but all I can get is a uniform color, even when I play with the spline or the UV projection
It's an absolute distance (in meters), you need to remap with a range shader.