Nevermind, I figured it out. Apparently, I was doing everything right and the desired outcome was already displayed on the screen. However, because I used such extreme values for camera.near
and camera.far
and enabled its logarithmic depth buffer, the values of the depth
variable in the fragment shader were exceptionally small, almost 0, so the colors were indistinguishable variations of white.
Multiplying depth
with a large factor like 360000000000.0
when getting the RGB of the final color in the shader helps in illustrating this. A minimal example of using depth to fade colors based on distance to the camera here.
EDIT: I also adjusted the WebGLRenderTarget
instantiation from the 5th link in my original post to make it more compact (since lots of defaults were used) and in the process I got rid of some mistakes in definining the object tree there.