Overview
Scenes that span huge distances (planets seen from orbit, flight simulators, open worlds) run into z-fighting: distant surfaces flicker through each other because the depth buffer cannot tell them apart. A reversed depth buffer fixes most of this. This demo renders a scene with a near plane of 0.1 and a far plane of 50,000 using reverseDepthBuffer, and runs it through an EffectComposer to confirm that post-processing still works.
How it works
A standard perspective projection maps depth non-linearly: most of the precision is spent close to the near plane and very little is left for distant objects. Floating-point numbers have the opposite distribution, with most of their precision close to zero. A conventional depth buffer therefore combines two sources of imprecision in the far distance.
Reversing depth maps the near plane to 1 and the far plane to 0. Now the far distance, where the projection is least precise, lands where floating-point values are most precise, and the two errors largely cancel. With a 32-bit float depth buffer the result is almost uniform precision across the whole range. In Three.js you enable it with new WebGLRenderer({ reverseDepthBuffer: true }); the renderer flips the projection matrix and depth test for you when the browser supports the required clip-control extension. The demo shows whether reverse depth is actually active on your device.
Exploring the demo
Fly towards and away from the distant geometry and look for flickering where surfaces nearly overlap. The vignette shader pass applied through the composer should look identical whether reverse depth is on or off, which is what this demo verifies: screen-space effects that do not read the depth buffer directly need no changes.
Practical advice
Custom shaders that read depth (SSAO, fog, depth of field) must account for the reversed range, so test effects that sample depth textures. Logarithmic depth buffers are an alternative but disable early depth testing and cost fill rate. For large outdoor scenes, also see cascaded shadow maps, the flight simulator and the mountains scene.