[WIP] Initial attempt at soft shadows
vec3 coordsProj = coords.xyz / coords.w; return float(coordsProj.z <= texture2D(shadowMap, coordsProj.xy).r);
I'm probably missing something very obvious here, any help would be appreciated.
What needs to be done before this patch can be merged:
- Fix the bug.
- Find out what's going on with the minimap glitches
- Consider tuning the parameters, maybe make some of the user-configurable?
Consider a different sampling kernel, currently it's a 25-sample Poisson disk.
- Changed to 16-sample Vogel disk with per-fragment rotations, has less visible artifacting thanks to being less uniform.
- Consider early-out to save some work if the results of some small number of samples are close enough that using all samples wouldn't make a difference? Or maybe use downscaled shadow maps for early-outs?
- Consider using texture views to access the 2×2 PCF for free.
- Be less dumb about the cascade — this one is a probably a must.
Make it possible to choose between sharp and soft shadows —
5032 shadow map samples plus some math ops per fragment is a significant number, weaker GPUs won't like it.