The previous implementation of useReverseDepthBuffer (in 4.2) is bugged: try using a camera.minZ value > 1 in your PG, the meshes will disappear.
This PR will enable the “infinite far plane” mode in reverse depth buffer mode:
Use camera.maxZ = 0 to enable “infinite far plane”. It’s the real setting that improves things when engine.useReverseDepthBuffer = true. In this PG that is using reverse depth buffer, you will see artifacts:
Try now uncommenting line 29 which sets the “infinite far plane” mode (it will only work once the PR is merged):
That’s because using a reverse depth buffer does not really improve things in WebGL. See Depth Precision Visualized | NVIDIA Developer for in-depth explanations. Also, logarithmic is not compatible with reverse depth buffer: use either one or the other.
So, in WebGL you should not use the reverse depth buffer but the logarithmic depth instead:
Note that you need to set a real far plane (the “infinite far plane” mode is not supported) for the logarithmic depth to work as expected (as the far plane value is used as part as some internal computations).
Note also that in WebGPU you should always use the reverse depth buffer mode as it is working as expected there, and you save some performance over logarithmic depth because we don’t have to set the depth in the fragment shader.