Why changing camera's far clip does not seem to clip the distance for depth map rendings? I am rendering depth maps and store the results in OpenEXR format. To make sure things work as expected I loaded one of the renderings into Python using the OpenEXR Python bindings as follow:

import OpenEXR, Imath, array

exrFile = OpenEXR.InputFile('depth.exr')
FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
(R,G,B) = [array.array('f', exrFile.channel(Chan, FLOAT)).tolist() for Chan in ("R", "G", "B") ] # R, G and B hold the same values
print (max(R), min(R)) # will print something like (10000000000.0, 0.9885767698287964)


Before rendering, I set the camera's clip end value to 2. What I noticed is that the clipping the camera distance does not change the large value in the rendering results. In other words, I will always have 10000000000.0 as the biggest number in the rendering result. I wonder, why doesn't the camera clipping seem to work here? Is there a way that I can clip the maximum depth distance?

I need this because when I need to be able to visualize the result. However, when I divide the numbers by the maximum distance everything is almost close to 0 and I cannot see anything on the screen. One solution that might work is to set the largest number to a much smaller value but this does not solve the problem fundamentally. So any solution would be appreciated.
This is essentially just a matter of interpretation and intended meaning. When the depth reports 10000000000 it’s not actually intended to represent an actual distance, rather ‘infinity’ (but it’s a suitably large enough value to essentially be regarded as that) and so it represents the rays not actually hitting anything. The camera clipping distance is effectively a tool to allow the render to be optimised (so we don’t consider details that are too distant to make a noticeable difference to the final render. It does affect which surfaces are considered for rendering but the ‘infinite’ depth is still relevant to indicate ‘nothing was hit’.

When interpreting a depth map it’s much clearer to interpret a single value (“infinity”) as an indicator that nothing was hit than a ‘variable’ value based on the camera clipping distance - maxing out at the clipping distance would require additional knowledge as to what the actual clipping distance was set to for that particular render before you could determine whether a point hit a surface or not.

If you know your clipping distance you should be able to manually limit the upper bounds with something like `min(9999,max(R))’ - ie, get the maximum value from R and then take the minimum of that and some constant based on your clipping distance.