Hello everybody !
I am integrating PCSS (percentage-closer soft shadows) with CSM (cascaded shadow maps) in GLSL.
The problem is that it is obviously not possible to do both, read the z-value from the shadow map (needed for the PCSS blocker search and done with sampler2DArray) and use the hardware accelerated depth comparison mode (needed for the percentage closer filtering (PCF) and done with sampler2DArrayShadow).
Meanwhile I use for PCF sampler2DArray as well and doing the depth comparison in the shader code, but I get a performance hit I would like to avoid. In the original PCSS code from the Nvidia web site HLSL shader are used and the shadow map can be accessed via the functions tDepthMap.SampleLevel with a PointSampler to retrieve the z-value of the shadow map and tDepthMap.SampleCmpLevelZero with a ComparisonSampler to do the hardware-accelerated z-comparison with 4 shadow map z-values.
The question is how to switch in one GLSL-shader between the hardware-accelerated z-comparison mode and the z-retrieval mode without a performance hit ?
The problem with GLSL is that I have to set the glTexParameteri( GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE) for the z-comparison and the glTexParameteri( GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_COMPARE_MODE, GL_NONE) for the z-value retrieval in the OpenGL-program and cannot switch between them in the shader !
Any ideas on how to do this without a big performance hit would be greatly appreciated !