High quality float depth packing into a RGBA8 buffers in WebGL 1.0

Right now we take a linear value split it up into four bytes:

https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/depthRGBA_frag.glsl

This is very imprecise.

But we could actually have the precision of floating point (mantissa/exponent) depth buffers while using RGBA 8-bit channel buffers if we adopt this encode/decode stuff:

http://stackoverflow.com/a/7237286

Author: Fantashit

1 thought on “High quality float depth packing into a RGBA8 buffers in WebGL 1.0

  1. Yeah, that is a good idea.

    I could implement depth texture support if it exists, otherwise it falls back to Float32 encoding, so that whether or not the extension exists, it has the same quality and same functionality. Right now the SSAO and DOF stuff in ThreeJS is pretty hard to use because the precision of the depth buffer is brutal.

Comments are closed.