I want to improve my shadow mapping depth precision by getting the minimum and maximum depth value within my shadow map. When having both values I would convert the depth map to convolution shadow map basis functions and encode the values to 8bit each, which looses precision a lot, in case the depth span is high.
Right now I render the scenario depth values into a R32F texture. A second shader checks for each pixel, if it is the min / max depth within the shadowmap by using SSBO and AtomicMax / AtomicMin. Then the next shader converts the depth values with respect to the min/max depth into the basis functions of convolution shadow mapping.
Is there a way to get the minimum / maximum depth during the render pass of the scenario? If this is the case, I could skip the second shader.
During the geometry rendering within the fragment shader I can get the depth value and use the AtomicMin / AtomixMax function. But when doing so, there can be the case (it happens very often) that fragments will be executed, which are behind other faces. so the max distance will be wrong at the end, which decreases the shadow map precision.
I found the layout(early_fragment_tests) in;
specification. But I am not sure if this will solve the problem. How does this specification work? Do you have other ideas?