I would like to output in my pixelshader the actual camera distance per pixel. This means, the result should (aside from some slight variations in precision and clamping) not depend upon the near/far clipping planes.
Also, a plane lying exactly on the near plane (and parallel to it) should therefore not output a uniform result, because pixels in the middle of the nearplane are closer to the camera than pixels on the border.
How can I calculate the actual camera distance for each pixel in a pixelshader? (actual shader language doesn't matter)