I am trying to make use of free hardware PCF sampling with sampler2DShadow and extend it to more samples.
So far I am sampling shadow map (sampler2D) in ESM way and extending this to PCF and it works. So I have no acne (thanks to ESM) and soft result, but I need a lot of PCF samples:
float shadowMapSize = 512.0; float c = 5000.0; float receiver = lightCoords.z; float shadow = 0.0; for(int i = 0; i < SAMPLE_NUM; ++i) { vec2 off = (POISSON_SAMPLES[i])/shadowMapSize; float occluder = texture(shadowmap, lightCoords.xy+off).r; shadow += exp(c*(occluder-receiver)); } shadow /= SAMPLE_NUM; shadow = clamp(shadow, 0.0, 1.0); But I wanted to use sampler2DShadow and get 4 PCF tabs for free and extend this to 16 taps for almost free with only 4 poisson samples like that:
float shadowMapSize = 512.0; float c = 5000.0; float receiver = lightCoords.z; float shadow = 0.0; for(int i = 0; i < SAMPLE_NUM; ++i) { vec2 off = (POISSON_SAMPLES[i])/shadowMapSize; float occluder = texture(shadowmap, vec3(lightCoords.xy+off, receiver)).r; shadow += exp(c*(occluder-receiver)); } shadow /= SAMPLE_NUM; shadow = clamp(shadow, 0.0, 1.0); But unfortunately it doesnt work as expected:
Is there a way to make it work (in ESM way, not traditional due to acne) or due to sampler2DShadow specification it is rather impossible? In traditional way it is possible.
