Search Unity

[Official] 5.0 - Feedback request for Directional Light Shadows

Discussion in 'Unity 5 Pre-order Beta' started by Aras, Dec 12, 2014.

  1. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    So 5.0 beta9 added PCF 5x5 filtering for directional light shadows (option under quality settings). That typically looks nice, and actually runs faster than the old screenspace blur filtering. However, it leads to more self-shadowing artifacts ("shadow acne").

    5.0 beta 17 (out today) adds so called "normal offset bias" to help with this. It's a setting on the Light; typically values of 0.3-0.7 look good (default is still zero, will change that later).

    Now, feedback we're looking for is: Does anyone need the old screenspace shadow blur method?

    Advantages of the new PCF 5x5:
    • Faster (my measurements, 30% faster; checked on Intel Iris Pro and GeForce GTX 680)
    • Shadows look nicer in many cases (less noise, less "wrong shadows around some object corners")
    Advantages of the old screenspace blur method:
    • "shadow softness" control on the light that spreads filter taps around. This is not easily possible in PCF 5x5 filter case.
    • Transition between shadow cascades is less visible
    • Smaller shadow bias is enough (i.e. less shadow acne).
    If anyone thinks we should keep the old screen space blur - we'd love to know the reasons why!

    (current plan is to remove screenspace shadow blur for Unity 5.0; it will be replaced with PCF 5x5 filtering)
     
    Last edited: Dec 14, 2014
    GoGoGadget likes this.
  2. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    199
    I have tested new filter. I have no idea about technique but it is much more better. I didn't see any transition visible between cascades. For me, no reason to keep older one if PCF 5x5 filtering is better for both performance and look nicer.
     
  3. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    283
    I'm always in favour of progress at the cost of reduced support for older platforms. Remove it!
     
  4. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    332
    Let the old one burn!
     
    Roni92 and AustinRichards like this.
  5. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    255
    the old method looked so terribly noisy that i wouldn't shed a tear if it vanished. one thing i wonder about is exposure of the shadow system? i'd like to see what the community could do with an extendable shadowing system. but i understand thats a lot to ask. =3
     
  6. cician

    cician

    Joined:
    Dec 10, 2012
    Posts:
    233
    I'd say say... remove it? Besides getting rid of the noise, my selfish reason would be it should make it easier for me to implement penumbra scattering in my skin shader with less #ifdefs. Or so I'd like to say, but I'll have to support Unity 4 for a while anyway.

    Here's what I meant by penumbra scattering, and a shameless plug:
    penumbra scattering.png
     
  7. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    Yeah, eventually it would be awesome to have it. Currently you can do quite a lot (e.g. Shadow Softener which works in Unity 3, 4 and 5), but having more extensibility would be awesome. Someday.
     
  8. SubBassman

    SubBassman

    Joined:
    Mar 28, 2011
    Posts:
    16
    How about a bool flag on objects that would turn Self Shadow on/off? This is common in 3D applications. Some objects don't need self shadowing whatsoever, artifacts could be lessened on problematic objects and rendering would be even faster in general. Just my 2 cents.
     
  9. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    That's a bit hard to do with shadow maps (since presumably you want to receive shadows from other objects, but not from the object itself; but also want the object to cast shadows onto other objects)...
     
  10. Cogent

    Cogent

    Joined:
    May 14, 2013
    Posts:
    357
    Not an issue for us.

    You have our permission to remove it. :p

    Cheers
    :cool:
     
  11. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    199
    U are the boss Aras. You can decide it. You always do best for us:D
     
  12. SubBassman

    SubBassman

    Joined:
    Mar 28, 2011
    Posts:
    16
    I understand your concerns, but... some organic objects (like a human face) can have really bad shadow artifacts. :) Another solution could be the perfect shadow, but it seems even harder to achieve. Programmingwise, is it possible to automatically increase shadow quality as the camera gets closer to objects? (and decrease it as it moves farther)
     
  13. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    170
    No problems here on DarkfieldVR with 5x5 PCF, except the usuale ones with flickering on very near shadows (near clip plane 0,1), but this is not filtering related. You can dump the old method for our part.
     
  14. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Those weren't just concerns. Those are limitations of the algorithm. Unless you want to be rendering a ton of separate shadow maps, you just can't have an object selectively shadowed by other objects and not itself.
     
  15. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    That's exactly what cascaded shadow maps do.
     
    shkar-noori likes this.
  16. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Drop it, it was a shame to have that for so many years anyways,
     
  17. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    im more curious when the point and spot lights will have the ability to have nicer soft shadows. Mind boggling how they still look like 4 combined hard shadows shifted over each other.
     
  18. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    That's high on the list, but most likely not for 5.0. (and yes, point/spot lights do exactly four shadow taps and average the results)

    For now, you can work around that locally by adding a custom version of AutoLight.cginc next to your shaders, that do more shadowmap taps. Or get something like Shadow Softener from the asset store to do that for you.
     
  19. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    Yea I was looking into shadow softener. Definently looks worth the money.
     
  20. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    762
    Is there a problem with leaving both options? Or just more upkeep?
     
    kurylo3d likes this.
  21. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    More things to maintain, more things to test, more options in UI, larger file size for built-in resources, and hardest thing of all, I have to come up with an enum name from a scripting API :)
     
    Gizmoi likes this.
  22. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    Yea i agree.. i like the idea of keeping both as long as somewhere in the documentation it shows a screenshot of the difference and the performance benefits of one vs the other.
     
  23. scarletshark

    scarletshark

    Joined:
    Jun 6, 2013
    Posts:
    33
    New version looks great! I was considering buying shadow softener, and this is exactly what the doctor ordered. Great job, team!
     
  24. cician

    cician

    Joined:
    Dec 10, 2012
    Posts:
    233
    I did a quick test of both and can confirm the trade-offs are just as described in the OP (the visual part, did not test the performance).

    PCF5 is more stable and penumbra size isn't fixed in screen space. Which is good, but you can't adjust the softness level or boost it like in screen space shadows.
    Shadow acne is worse and to get rid of it you have to up the bias to a value that makes things floating too much. Just like in Unreal Engine 4, which uses PCF shadows.

    If you find ways to limit the acne then, sure remove screen space shadows. Otherwise I'm not so sure.
    And please, pretty pleease: definitely let us customize it and/or provide PCF8 or better.
     
    shkar-noori likes this.
  25. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    I actually like being able to make the shadows softer and blurry looking.
     
  26. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    Did you try using Normal Bias, instead of regular bias? Normal bias does make shadows slightly thinner, but does not create "disconnect" between caster and shadow.
     
    shkar-noori likes this.
  27. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    185
    Another thing you guys should add is a depth/normal bias value per cascade!

    I noticed shadows flickering far away and if I could change that bias without having to sacrifice close shadow quality that would work
     
  28. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    Normal bias tries to do exactly that. The units of bias are in "shadow texel size in world space"; that is calculated for each cascade.
     
  29. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,329
    Even with PCF 5x5 filtering, shadows still flicker horribly inside a cockpit.

    It is clearly not designed for that.
     
  30. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    226
    What about shadows casted by semi-transparent object? They look.... hmmm they don't look at all :p
    I mean its just some strange grid that becomes denser when lowering transparency.
    tested @b17, with standard shader with transparency.
     
  31. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,343
    My overall feedback:

    1. I like the dithered transparent shadows, especially with PCF.

    2. I find with the right cascades, dir shadows can be really sharp close up or even soft - I just lower the res a bit, so with balance.. I don't miss the slower shadows. Plus you know me Aras. All I will do is embrace speed. This faster? Yes, yes. This is used :)

    3. Overall the only problem I have is that objects which don't cast or receive shadows in the distance makes the overall resolution lower, as if they are included in the bounds of the shadow depth buffer. Maybe a bug?

    4. The join between cascades is visible with 2 cascades but not really a problem with 4. Not a bad trade off for the speed so I am ok :)

    One thing I was thinking was it would also be nice to adjust the fade out value, when it is out of range. Back when we were doing Vita stuff, we gained speed here also because it meant our shadow distance could be closer... there is some waste of shadows when you fade out too soon.

    Aesthetically a shorter or longer fade range suits a visual style better. Regardless I don't really need this, it was just a thought. I guess current range is the best safe range where you cannot see artefacts. Whatever :)
     
  32. smetzzz

    smetzzz

    Joined:
    Mar 24, 2014
    Posts:
    137
    I'm not getting any shadows on iOS. xCode throws a lot of the following errors. I haven't tested too much, I could be missing something too.

    ld: warning: direct access in Enlighten::InputLightingValidation::CheckForMalformedLightTypes<3>::Check() to global weak symbol guard variable for Enlighten::InputLightingValidation::CheckForMalformedLightTypes<3>::Check()::testIsMultipleOf16 means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
     
  33. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    File a bug with repro! Shadows are working here on iOS.
     
  34. smetzzz

    smetzzz

    Joined:
    Mar 24, 2014
    Posts:
    137
    It seems like Playmaker was messing with the beta. After I deleted all the playmaker I spent the next two weeks coding everything in javascript. All good now.
     
  35. Shapefarm

    Shapefarm

    Joined:
    Dec 10, 2014
    Posts:
    17
    Any plans for delving a bit deeper in this to really harvest the potential of PCF filtering? There's a ton of stuff you can do with it: http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf

    I'd love support for PCSS. I'd be great to have more control over the shadow color (gradiation, coloration etc) as well, even though you might be better of doing that in the shader that receives the shadows?
     
  36. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    No immediate plans on our side. Our current plans are like this: "for 5.0, we're done with shadows"; and later on (5.1 or 5.2 or whatever), biggest shadow related things are IMHO:
    • Quality improvements for mobile (e.g. optional cascaded shadows)
    • Shadows on semitransparent objects
    • Point/Spot light shadow filtering improvements
    • VR optimizations (e.g. sharing shadowmaps between the two stereo rendering cameras)
    • API access & customization - e.g. ability to stop automatic shadow updates; manually render shadows from a script call; etc.
     
    Andrew-Saraev and protopop like this.
  37. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    226
    Thats weak bro ; I was hoping for some more improvements ;
     
  38. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    I listed what we think are "top 5 highest priority things in shadows". You think something else should be on the list, instead of what I wrote? Suggestions are welcome!
     
  39. Shapefarm

    Shapefarm

    Joined:
    Dec 10, 2014
    Posts:
    17
    I think that the shadows are one of the weakest points in the real time pipe at the moment. PCF is cool, but it's pretty ugly without some noise breaking up the filter pixels, or even the ability to at least raise it to 9x9. Also the inability to change the softness of the light produces an unnatural (and jaggy) shadow which is infinitely semi-sharp. Overcast lighting can't simply be done. Now you can discuss if you really want to spend GPU cycles on nice blurry soft shadows, but i'd say that's something that should be decided on a per project basis, not as an engine limitation.

    There are a huge number of techniques to choose from, many a bit more modern than PCF, as i'm sure you're aware of already. Distance field, convolution, sh exponentiation etc.
     
  40. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    for overcast shadows couldnt you just use some trickery like an alpha mask for the light? I mean im all for soft fading shadows, but that example isn't a very good one since its not vital to do all that extra work for something that can be done another way.
     
  41. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    I agree all that would be nice. Which item of my "top 5" list above would you remove in order to make room for these? "Top 5 priorities" lists have only 5 items on them by definition :)
     
  42. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    226
  43. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
    Not everyone can afford to lose WinXP/Mac/mobile support, spend 500 megabytes of VRAM on distance fields and not have shadows from animated/deforming objects :)
     
    mh114, kurylo3d, m4d and 1 other person like this.
  44. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I would drop Quality improvements for mobile and add higher PCF quality filtering for at least current-gen shadows..
     
  45. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    burned. lol
     
  46. Shapefarm

    Shapefarm

    Joined:
    Dec 10, 2014
    Posts:
    17
    Haha! True, not all would do want to loose that support, but WinXP is not even supported by Microsoft anymore. I totally agree on that you don't want to loose support for mobile/mac. You should ofc have the choice of using PCF (it's there already). And i really do agree with Shkarface that a higher filtering option would be the best way to go for now. I'm not sure the mobile devs would like to loose that quality improvement though...

    On the current gen consoles 500mb of vram is not much. I wouldn't say that it's hard to use up the 3-4gb of vram you can get out of the unified ram architecture (current get consoles) on pure textures, but i think that anyone would agree that even a super sharp texture would look bad if it had a jaggy shadow moving over it.

    Now baked shadows are great. You can even have them on big semi-open world games like Battlefield 3. They require really good tools, really good tech artists and a looot of time. They also come with the limitation that day/night cycles etc can't really be done if you don't choose to bake only the enlighten meshes/maps, but then you still have jaggy shadows from the sun (with the current filtering). They also have a practical world size limit (manpower and optimization time), even though theoretically you can bake and sustain (with streaming) a huge world.

    kurylo3d, you can fake it at some extent for dynamic objects, but only if you have a static light source like the sky. We can't do it on Vane because we're not baking lights since we have a dynamic light setup with the sun moving around like crazy in some scenes. Time lapses with day&night etc.

    Sorry for the wall of text! In the end it's all up to the Aras and his fellow coders to work on the priorities. I just want to see Unity actually seal the deal and make the graphics update complete and solid. To choose between PCF 5x5/9x9 would be a good start. No point in using PCF filtering if you're not taking it all the way imho.
     
    shkar-noori likes this.
  47. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    Id be careful comparing consoles to pc games. Pc games may have more powerful gpus, but the fact of the matter is most people still have less then 1gb of video memory on their gpu. Consoles have the luxiory of sharing their graphics memory with other things... giving them around 8gb. But more features are always welcome either way.
     
  48. Shapefarm

    Shapefarm

    Joined:
    Dec 10, 2014
    Posts:
    17
    Oh yes it's very much so. But PC is great in the way we can detect what specs the user is system has and make custom settings per machine.

    8gb is kind of a marketing number. After all the system OS memory has been allocated you're happy to get a bit under 4gb (which is still dev heaven after the last gen stuff!)
     
  49. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,366
    • Pcss
    • Contact Hardening Shadow
    • Shadow soft value
    • Prebaked static shadows
    • Spherical & Capsules Ambient Occluder please (this can be considered as shadows right? :p )
     
    Rodolfo-Rubens likes this.
  50. BigRedSwitch

    BigRedSwitch

    Joined:
    Feb 11, 2009
    Posts:
    723
    Shadows don't seem to be working on mobile at all in RC3 - just so you're aware.