In my deferred renderer, the depth buffer holds values in the range from about 0.9700
to 1.0000
. I found this out by drawing pixels in a given depth range black. This is the shader code I used.
bool inrange(in float position)
{
float z = texture2D(depth, coord).r;
return abs(position - z) < 0.0001;
}
void main()
{
if(inrange(0.970)) image = vec3(0);
else result = texture2D(image, coord);
}
And this is how it looks like. I tried several depth values. This image is for the depth value 0.998
.
I use a as texture of the type GL_DEPTH24_STENCIL8
and format GL_FLOAT_32_UNSIGNED_INT_24_8_REV
as depth and stencil attachment.
Is there an explanation for my depth values to be in this range? Is it default behavior? I would like them to be in the range of 0.0000
and 1.0000
.