Skip to content

[WIP] Initial attempt at soft shadows

Fanael Linithien requested to merge (removed):sss into master

#4852


This implementation is mostly inspired by CHS. It's currently incomplete and buggy, but when it works, it works rather well, compare master: master and this patch: sss

It is currently buggy, it has a tendency to glitch out when looking almost directly at the ground:glitch This happens even if sampleShadow is just simply:

    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 — 50 32 shadow map samples plus some math ops per fragment is a significant number, weaker GPUs won't like it.
Edited by Fanael Linithien

Merge request reports