Result of textureGather() is different from result of texture()

Hi, all!

I try to optimize my shadows.
There is the problem:

The value of textDepth in:

  uniform sampler2DArrayShadow dlShadowMap;
  ....
  float bias = 0.0005;
  float correctedDepth = projCoords.z - bias;
  float textDepth = texture(dlShadowMap, vec4(projCoords.xy, idx, correctedDepth));

is different from:

  uniform sampler2DArrayShadow dlShadowMap;
  ....
  float bias = 0.0005;
  float correctedDepth = projCoords.z - bias;
  vec4 baseTextel = textureGather(dlShadowMap, vec3(projCoords.xy, idx), correctedDepth);
  float textDepth = baseTextel.x;

For all of baseTextel.x, baseTextel.y, baseTextel.z and baseTextel.w.

Why?

Filtering of shadow textures (depth textures with ref-to-texture comparison enabled) is implementation-dependent. textureGather would be expected to yield values which are either 0.0 or 1.0, while texture may perform some kind of filtering. The wording of the 4.6 specification is (8.23.1):

Hmmm…
It explains why I have good result with shadow casting using too small bias = 0.0005. It is possible because of linear approximation.
So, if I use NEAREST flag I’ll have exact value for both of ‘textureGather’ and ‘texture’ functions. Am I right?

That should be the case. …

Thank you, GC!
Have a good day!