So I'm trying to render the depth map of a scene using three.js
An example can be found here: http://threejs.org/docs/#Reference/Materials/MeshDepthMaterial
The depth map looks good when the scene is setup carefully, for example:
camera.position.z = 30;
camera.near = 0.1;
camera.far = 50;
object.position.z = 0;
However, if the camera is setup in some other ways, for example:
camera.position.z = 600;
camera.near = 550;
camera.far = 650;
object.position.z = 0;
In the second example, the depth resolution is all taken up by the depth range from -45 to -50 in the world coordinate system. This means for -50 < objects.position.z < -45, you can still see grayscale values in the depth map. Anything that has depth ranging from -45 to 50 will appear completely white in the depth map...
Ideally, I would like to see depth values uniformly distributed in the -50 to 50 range.
Is there a way to get the depth map I want? Is there a way to increase the precision of depth map?
Eventually, I would like to save the Depth Map of the three.js scene as a .png image on to local disk for some analysis. Methods that don't use three.js are also welcome. Thanks.