Conflict of the glPolygonOffset() with "Shadow Map Silhouette Revectorization" technique

Found and implemented solution.

Build composite frame buffer with depth and color textures.
While rendering depth map:

  1. Render adapted depth data directly in depth buffer.
  2. Calculate real depth value in attached fragment shader.

The most difficult was correct calculation of depth:

#version 430

out vec4 fragColor;

in VBlock {
  vec4 position;
} vIn;


void main() {
  float far = gl_DepthRange.far;
  float near = gl_DepthRange.near;
  vec4 pos = vIn.position;
  float val = pos.z / pos.w;
  float depth = (((far - near) * val) + near + far) / 2.0;
  fragColor = vec4(depth, 0, 0, 1.0);
}

That little bit slower than default depth mapping (without fragment shader) +6 ms.
But much much faster that 2 different passes.

The glPolygonOffet let me dramatically improve shadow quality avoiding any “peter panning”

The very good result for me.