I'm trying to use Three.js's MeshDepthMaterial, however it is not working quite how I am expecting. Maybe I misunderstand how the material is supposed to work, but I'd assume that it determines "how white" the material is at a given point using the camera's near and far settings from a given camera position. So if my camera is at (0, 0, 0) with a near of 1 and a far of 1000, and I have a cube place at (0, 0, -2), I'd assume that the cube would be very white (1 - .002 = 99.8% whiteness).
However, that has not been the case. Using a near and far of 1 and 10 respectively, with the back cube placed approximately 10 units away from the camera, this is how the material renders.
As you can see, the material for each cube is nearly all black, despite the nearest cube being 4 units closer.
As seen here, I have to get extremely close to the cube to see strong whiteness, and even then, the far corners of the cube which are not even 1 unit away are strongly gray.
These results also remain constant if I change the far to 1000 instead of 10.
Am I misunderstanding how MeshDepthMaterial works? Here's my code:
renderer: new THREE.WebGLRenderer({antailias:true, logarithmicDepthBuffer: true}),
scene: new THREE.Scene(),
camera: new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10)
....
this.renderer.setSize(window.innerWidth, window.innerHeight);
this.renderer.setClearColor(new THREE.Color(0x00000, 1.0));
this.renderer.shadowMap.enabled = true;
this.scene.overrideMaterial = new THREE.MeshDepthMaterial();
this.camera.position.z = 4;
....
this.createCube(-3, 0, -4, "#FF1215");
this.createCube(0, 0, -2);
this.createCube(2, 0, 0, "#FF7232");
Where the parameters for createCube are the positions