I’m trying to use (externally rendered) depth textures (32-bit, rgba packed) in a depth prepass, so that all subsequently rendered geomtries will be depth-tested against this custom depth buffer.
I’m using a custom shader on a full screen triangle to write the unpacked depth value into gl_fragDepth. However, geometries that render after the prepass are not occluded as expected. The depth test seems to be kind of inverted, but not really (???).
Maybe I’m missing something fundamentally here…?
I added a picture to better illustrate what is happening:
I also created a codepen. The only difference is, that instead of loading an external rgba-packed depth texture, the texture is created on the fly (in the “Pack” mode). In the “Prepass” mode, this texture is then used as described above. You can switch between the modes with the two buttons.