Author Topic: Percentage-Closer Soft Shadows (PCSS) - Dynamic Soft Shadows based on distance  (Read 5651 times)

https://pastebin.com/XJNYumvQ
* based on port's poisson disc shadow shader, and includes minor modifications by me, and distance is not distance from the camera anymore...
See http://developer.download.nvidia.com/shaderlibrary/docs/shadow_PCSS.pdf
There are issues with blending between shadow cascades, but I'm satisfied with the results. This isn't really ready to use all the time since I messed up some stuff but it'll be fine for a demo. Certain settings make the shadows simply get lighter with distance as well, rather than softer, especially with distant objects. The shadow map resolution matters too with what the effect ends up looking like (lighter shadows vs correct softening), something which I tried (and apparently failed) to mitigate.
Preview:
« Last Edit: January 21, 2018, 07:34:23 PM by QuadStorm »

This is what I've been trying to release for a while, I just kept getting the same shadow cascade blending issue as you have here so I was never satisfied with it. How's the perf?

This is what I've been trying to release for a while, I just kept getting the same shadow cascade blending issue as you have here so I was never satisfied with it. How's the perf?
I get around 30 FPS with the fixed softness shader, and 25-28 FPS with dynamic softness with the device I'm using and looking at MotE Mansion's shadow.

one step closer to real life in bl

Quote
void applyLighting(inout vec4 combinedColor, vec4 albedo, float occlusionFactor)
{
   //large normal means glowing object
   if(glow == 1 || (worldNormal.x + worldNormal.y + worldNormal.z) > 2.0f)
   {
      combinedColor = albedo;
      return;
   }
 
Change combinedColor = albedo; to combinedColor = albedo*1.5; to have off-like glowing effects.
From left to right is off, max w/o albedo change, max w/ 1.5x.


I'll definitely add this as a 'superGlow' option for any shaders that I edit in the future.

i still prefer ports over this because it doesent bone your fps

i still prefer ports over this because it doesent bone your fps

mine definitely does that too

mine definitely does that too

i get around more than 60 fps with your soft shaders

Maybe try hacking the frustum slice distances via memory editing... an easy way would be setting 0x70CC28 to the lambda value as per the nVidia paper blockland's shadows are basically copied from, so what the lambda value/split_weight variable would be in updateSplitDist. Higher means splits are shifted towards the camera, lower is farther.

Blockland's slices are already pretty spaced out compared to what you'd see in games like GTAV, but I guess with PCSS its not really a priority to have crispier shadows anyways. See if messing with the slices does anything, otherwise it might be one of those things we have to "deal with" just like in GTAV- any method to nicely blur the lines is likely beyond shader edits or simple hacks. Just one of those things to tweak until it is right, as we all know it's what we sign up for when messing with shaders anyhow :P

Also the fact that a lot of this technology has been around since forever makes one wonder why they didn't deck out the shaders with it when they were released. It looks like the original thread had some form of softened shadows too... but if their lack of existence tells us anything I'd guess they scrapped the idea because of some visual error/sacrifice. I wonder what!!

That looks like hata's soft shaders...

That looks like hata's soft shaders...
The shadows get sharper closer to the object that's casting it


https://pastebin.com/9D4n31Qu
Shadows should be consistent through quality levels (shadow map resolutions), and some useless stuff was removed. Still only a demo file of sorts. Blending hasn't been changed, and I haven't been able to clamp the poisson sample distance right for some reason. Lower lightSize and higher searchDivisor (probably should've done it 1 / float instead) values tend to look better, but if searchDivisor is too high you end up with a lightening rather than a softening shadow effect.
Note that I changed the superGlow code from what Pah1023 posted, since semi-transparent glowing objects are turned opaque from multiplying albedo and not excluding the alpha part.
« Last Edit: January 26, 2018, 10:57:41 PM by QuadStorm »

Third major revision: new poisson disk, clean up of some stuff, ultra mode works, and the fixed (no PCSS) mode toggle works correctly all with blending. Variable names have also been changed around to be more representative.
https://pastebin.com/gr2xzqAA