Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[Next-Gen Soft-Shadows 2] Sophisticated dynamic penumbra Shadows for Unity

Discussion in 'Assets and Asset Store' started by tatoforever, Nov 8, 2016.

?

Would you like to buy this on the Asset Store? If so, how much?

Poll closed Jul 10, 2017.
  1. I like it to be priced between 20 to 10$.

    56.8%
  2. I like it to be priced between 10 to 5$.

    39.0%
  3. Zero $, I'm not interested, I love my Unity's default aliased, pixelated horrid-shadows.

    4.2%
  1. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    193
    you are very kind
    thank you!!!
     
    jcarpay and tatoforever like this.
  2. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    193
    I can not do anything but send you my congratulations and great applause.

    My game has totally changed. The shadows are sensational realism.

    Thanks a lot!!!!!
     
    OCASM and tatoforever like this.
  3. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    65
    @tatoforever Hey bro! This post is not related to NGSS, but i'm wondering.. Is there a way, to make "inverted" Ambient Occlusion, that will drop light on objects from emissive textures ?




    SSR can give something similar to what i want.. But it's not it, and can lead to weard artifacts
     
  4. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    124
    Yep! HBAO does this effect, though they call it color bleeding. You can overdrive the brightness and cast light onto surrounding objects. It aint perfect, but if you find good settings it can look hella awesome. https://forum.unity.com/threads/horizon-based-ambient-occlusion-hbao-image-effect.387374/
     
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    The only proper way to revert this side effect is by applying AO as shadows instead of combining it with final color. There's other hackish ways to mitigate the issue (as described by Howard) but the clean way is making AO part of lighting instead of final image (as a post-process effect).
    This is what I'm doing with my SDFAO (got a video on youtube demonstrating this effect).
     
    Last edited: May 7, 2019
    Flurgle, OCASM and alternativevisual like this.
  6. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    More improvements to PCSS in v2.1. Fixed a weird issue that was breaking Spot Shadows. It's all good now:

    upload_2019-5-14_17-1-14.png
     
    Invertex, OCASM, bac9-flcl and 3 others like this.
  7. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    I can't seem to be able to configure PCSS min to max softness transition distance - no NGSS_Directional property seems to have an effect on that. Can you point me in the right direction for making PCSS shift to max softness over a given distance @tatoforever

    P.S. 2.1 looks awesome! :)
     
  8. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @bac9-flcl,
    Not sure to understand what you mean. You can't configure PCSS min and max softness on directional shadows?
     
  9. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    I don't see any softness gradient in directional shadows at any distance, the softness of shadow edges seems to be locked at the lowest defined value no matter how far a surface is from a shadow caster. I see differences when I change global smoothness or slide miminum smoothness value around between 0 and 2, but I never see shadows actually transitioning from sharpness to softness, no matter the distance. What could be the cause of that? I'm using legacy deferred rendering in 2019.1.2f1, if that's important, but I had exact same issue throughout the whole 2019 cycle. I have verified that directional shaders NGSS comes with are installed in the Editor folder and shader cache was rebuilt, not sure what else to check.
     
  10. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    Can you post images of your directional shadows setup?
    What's your computer specs?
    Seems like PCSS is not supported by your GPU.
    In v2.1 I changed the algorithm to increase the sharpness and softness quite a lot for PCSS but still, in the current version you should see sharp at near and soft at far distances with PCSS enabled.
     
  11. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    I'm using GTX1080 with the latest driver release (430.64) and the project is configured for PC/DX11, so the effect couldn't be unsupported. Here is the setup, maybe something is misconfigured there?



    Edit: Something suddenly recompiled when just randomly started changing PCSS related settings in the directional sample scene from NGSS. Now the min/max softness settings are no longer ignored in favor of uniform softness and I'm getting a proper PCSS softness gradient. Copying component configuration from the sample scene to my scene, I see that the settings make absolutely no difference, and it was a matter of triggering recompilation of some shader.

    Since I've completely cleared shader cache after installing NGSS files and PCSS still failed to show up initially, what could have triggered compilation of requisite variants when I was editing PCSS properties in your sample scene? Is there some additional trick I need to know about to correctly replicate this on every other machine we use on our team?
     
    Last edited: May 19, 2019
  12. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    When you install NGSS in a computer, make sure you clear shaderCache for all the projects you use it (or after installing a new version of Unity or NGSS). Also, re-importing custom shaders that has local include files can fix any issue (this is probably the problem you where having).
     
  13. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,943
    @tatoforever - Is it possible that NGSS doesn't install properly on 2018.4?

    It's unhappy on import, and there's no obvious way to follow the install directions. For instance, there is no Install Wizard.

    Assets\Psychose Interactive\NGSS\Editor\NGSS_LibrariesSetup.cs(39,41): error CS7036: There is no argument given that corresponds to the required formal parameter 'target' of 'StackTrace.StackTrace(IStackTraceObject, bool)'
     
  14. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @hopeful
    Going to check that out right away.
    [EDIT] Triple checked and everything is working fine on latest public 2019 and 2018 versions. Make sure you run Unity in administration mode before running NGSS installer. And also make sure you don't have any editor script compile error.
     
    Last edited: May 19, 2019
  15. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,943
    Okay, it looks like it was having a conflict with a scriptable objects package I'd loaded. Sorry about that, I should have tried it in an empty project before bothering you.
     
    tatoforever likes this.
  16. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    495
    Do you have a link and/or further information?
     
  17. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @christoph_r,

    Disclaimer: this is an old crude early version! :D
     
    Elecman, OCASM and ftejada like this.
  18. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    How can I control the distance at which softness reaches the "SOFTNESS_MAX" value? I might be misunderstanding something, but it seems that the distance is extremely large, because the softness shifts extremely slowly relative to size of shadows from normal-sized objects like standard trees. Here is a screenshot of global softness set to 10, min softness set to 0 and max softness set to 2: the most extreme, noisiest, widest possible configuration of PCSS, just to show the issue:



    PCSS is there, but it's pretty subtle for totally extreme inputs like these. And here is a screenshot with global softness set to 10, minimum softness set to 2 and maximum softness set to 2:



    The difference in softness radius is staggering, which is why I'm guessing that the distance min-to-max interpolation takes place over is quite large. Maybe there is another reason, but I'm not sure what it could be.
     
    Last edited: May 21, 2019
  19. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @bac9-flcl,
    I understand what you mean, currently (public version), there's no good way other than tweaking by hand till you are pleased with results. I have improved the algorithm a lot in v2.1, here's how it looks now with very extreme values (pcss_min 0, pcss_max at 2 and very high global softness):
    upload_2019-5-21_16-27-27.png
    upload_2019-5-21_16-29-36.png
    Obviously, using very extreme values at some point will break the algorithm and introduce artifacts/noise but it's being handled quite well and a lot better than current public version.
    In v2.1 we also have this kind of functionality and flexibility for local shadows (access to min/max values of PCSS shadows). :)
    [EDIT] Btw, you should always test shadows quality against your game/project, the provided test scenes are ultra low frequency for extreme test purpose only but NGSS shadows works better with high frequency detailed medium because of it's random sampling nature (noise is unnoticeable with highly detailed textured models and you can reduce quality for more performance without degrading visuals). In our current game console we do ~4-6spp for all lights and still look great and soft.
     
    Last edited: May 21, 2019
  20. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    Generally, I'd love to have an option to tweak not just minimum/maximum softness, but also maximum softness distance independently. Without the latter, you're limited in a way similar to not having a radius argument for ambient occlusion or a light radius property - yeah, you can tweak it somewhat, but you can never fully tailor it to actual depth range of your environment to leverage the effect to the fullest. Right now, the interpolation distance seems to be somewhere within 50-100m range, which is far too much for most scenes in our turn-based game: I had to create 100m tall pillars placed a fair distance away from the shadow receiver in our level to actually see full softness exhibited:



    I agree with your point on testing shadows on real geometry and using more reasonable settings, I'm only using extreme settings to track down the issue and find exact interpolation range NGSS is currently hardcoded to. :)

    Specifically in our game, I'd love to set NGSS properties proportionally to maximum height of features in a given generated level - that way, we'd never use excessive softness in any playable areas observed by game camera. If interpolation distance is not configurable and is hardcoded to, say, 100 meters, then a task of getting softness of 2.0 at 10 meters requires you to set max softness to 20.0. If you never actually desire to sample shadows at more than 2.0 softness, this is not the best way to configure the effect.
     
    Last edited: May 21, 2019
  21. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @ bac9-flcl
    Version 2.1 will allow you to control these properties a lot more and have a better range between sharp/soft transitions like my two examples above. If you want to give it a go the actual implementation send me an email to support. :)
     
  22. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    Good to know, eagerly awaiting the release then. :)
     
    tatoforever likes this.
  23. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @bac9-flcl,
    Your game seems like a perfect candidate for ShadowCaching. A new feature coming to v2.1 that saves tremendous amount of CPU/GPU time by avoiding rendering static geometry (it only gets rendered once or when you tells it to) reducing also drawcalls to only dynamic/movable objects. Would you like to test v2.1 when it gets to preview state?
    Cheers,
     
  24. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    264
    Would've liked to know more about this caching technology. It could be exceptionally useful for our current project, but for some situations it might not work due to the huge play area. Also wonder if the cache system could be applied per-cascade (to update each cascade sequentially, if it even uses the same structure as directional shadowmaps). Can it be used as a substitute for distant shadowmask?
     
    Last edited: May 22, 2019
  25. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @Kolyasisan,
    The ShadowCache system is perfect for any project with large amount of visible static meshes. If your game has very few static meshes (stuff that never moves) then you don't need to turn it on.
    Right now only Directional shadows is supported and that also means the whole cascades because I don't have control of that part with built-in renderer. But once I fully port NGSS to LWRP and HDRP yes I will provide ways of updating some of the whole atlas (not just what cascade but also what light). Another good benefit of this system is that DepthMap for ShadowCache is created when the scene loads (only once) and then you control when it updates minimizing both spikes and GPU cache miss as it stays on the GPU the whole session (till the scene/app holding it is destroyed).
     
  26. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    Absolutely! Our game is using a custom compute pipeline to heavily optimize how things are rendered, but shadow caching would be a huge boon to us.
     
    tatoforever likes this.
  27. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @bac9-flcl
    Will le you guys know here once is ready to be tested. I should have a preliminary version sometime next week! Still other 2.1 features to be finished but these ones are close to be done/testable! :)
     
    gecko and alternativevisual like this.
  28. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    385
    if you have a large number of static meshes casting shadows, wouldn't baking your lighting (and therefore your shadows) provide the same benefit?
     
  29. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    Baking is not practical for geometry generated in a middle of a game.
     
    tatoforever and ceebeee like this.
  30. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    Exactly, plus baking extreme large terrains with plenty meshes is close to impossible, long, tedious and the quality is horrible anyways. ShadowChaching technique is perfect for low-end devices and mobile too. ;)
     
    ceebeee, gecko and hopeful like this.
  31. EulogyForTheFallen

    EulogyForTheFallen

    Joined:
    Nov 15, 2016
    Posts:
    2
    @tatoforever Hi, quick question. It's been more or less answered before in this thread, but I want to make sure before buying. Can sprites cast and receive shadows with this plugin? We have a 2.5D project where the characters are animated 2D sprites but the environment is 3D:
    upload_2019-5-23_14-28-46.png
    As you can see, we've already gotten shadows working on the sprites with the default unity shadows through a custom sprite material and shader, but the sprites and models have peter panning even with 0 bias. So will the plugin work for us? Also, you mentioned in a different post that the plugin has more settings to fine-tune the bias to avoid artifacts like peter panning and acne. With this plugin do you think we'll be able to completely solve our issue?
     
  32. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @EulogyForTheFallen,
    If your custom material/shader works with default Unity shadows then yes it should work out of the box with NGSS. However if you are doing funny stuff with the rendering I cannot answer that question.
    If you want, you can send me a portion of your game with your custom shader and I can take a look at and test it for you and confirm that it works with NGSS (normally It should but we never know). Email address is: support AT psychozintearctive DOT com.
    I can always offer full refund if NGSS doesn't suit your needs.
     
  33. EulogyForTheFallen

    EulogyForTheFallen

    Joined:
    Nov 15, 2016
    Posts:
    2
    Nah, we're not really doing anything funny with rendering... yet. This should work for us, thanks for the fast response.

    Edit: Everything looks great, Thanks.
    upload_2019-5-23_17-49-21.png
     
    Last edited: May 23, 2019
    hopeful and tatoforever like this.
  34. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @EulogyForTheFallen
    I forgot to mention that default Unity shadows has some hardcoded bias values, with NGSS we can really push the bias quite close to zero and depending on your shadows settings shadows acne can be unnoticeable (due to the high amount of softness) so is another hidden free feature of NGSS. :)
    PS: Looking great btw!
     
    EulogyForTheFallen likes this.
  35. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    917
    Hi @tatoforever, i don't have the time to look through the forum thread so i will just ask a quick question.

    How are the shadow distances compared to Unity lights ( well mainly for directional lights ) ?
    Can we get shadows at longer distances with your system or they are mostly the same ?

    Thanks !
     
  36. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @Vagabond_,
    NGSS uses the same built-in depthmaps as default Unity shadows. However with NGSS you can soft the shadows and increase the shadowmap size a lot more. You can combine them with NGSS contact shadows too.
    Regarding infinite shadows I'm also working on newer techniques such as voxel and raytraced but they are out of reach right now. :)
     
    Vagabond_ likes this.
  37. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @Vagabond_
    You can give it NGSS a go and if you don't like it you can ask for a refund. I offer 100% satisfaction or money back. :)
     
    alternativevisual likes this.
  38. Zyblade

    Zyblade

    Joined:
    Jul 1, 2014
    Posts:
    91
    But I got 120% satisfaction, so I can keep using it and get also the money back^^?
    Joking aside, any eta on 2.1? Those new primitive shadows can't wait to be used in my project :D
     
    tatoforever likes this.
  39. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    I'm still fighting with Shadows Cache and once done will get back to finish some stuff on Primitive Shadows. :D
    Still targeted for this summer thought! ;)
     
    Zyblade likes this.
  40. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    272
    @tatoforever Let me know if you need any LWRP beta testers. :)
     
    tatoforever likes this.
  41. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    Early bailing out algorithm improvements in v2.1:

    To see what's really being filtered I've purposefully inverted the bailing out. First white (or transparent) and then black. Notice how the penumbra is not affected.
    Aggressively discarding fully lit & fully shadowed pixels without affecting quality. This allows you to crank the filtering sampling as the biggest part of the scene is either fully lit or fully shadowed! The cost of your shadows is mostly tied to the testing algorithm.
    In other words, more quality and more performance for free :)

    PS: Incoming Shadow Cache video soon! ;)
     
    OCASM, hopeful, ceebeee and 5 others like this.
  42. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    Improved Denoiser on v2.1:

    Demonstration of the new powerful denoising capabilities of NGSS in v2.1 removing high frequency noise on 8spp shadowmap. More quality for free!

    Also, not visible in the video but there's minor improved dithering too, looks a lot better with low sampling. Even without denoiser.
    [EDIT]
    Replaced the video with the correct one. Only 1 denoise iteration by default!
     
    Last edited: Jun 12, 2019
    OCASM, ceebeee, gecko and 3 others like this.
  43. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    OK folks,
    So I'm submitting right now v2.1 but it does not have Cached Shadows nor Primitive Shadows nor Contact Shadows for local Lights. I've been working on those features but lately shifted my focus on fixing a couple of issues and improving the speed of current version and that's what is v2.1 for. Instead of delaying these improvements why not release them right away? I will then release in v2.2 Cached Shadows, the new improved Inspector and either Contact Shadows for Local Lights or Primitive Shadows (the one that feels more ready) and so on. :D
    The good thing is that Cached shadows is almost done, testing starts this week and submission should happen in a week or two following tests! :)

    Alright so fixes, additions and changes in v2.1:
    - Early bailing out improvements, same shadows but faster to render
    - New improved Denoiser, faster and better with exposed options to tweak
    - Directional PCSS near & far distances behave better
    - Local PCSS near & far distances exposed on Local light component
    - Added spot & point shadows blocker search bias, also exposed on the light component
    - Removed & Replaced unnecessary conditional branches on all shadows types making them slightly faster
    - Fixed a bug with spot shadows that created weird artifacts when light range was too large
    - Minor improvements to dithering algorithm for all lights
    - Minor improvement to point light bias
    - Updated documentation

    Although both Local and Directional Inspectors will change in v2.2 this is how they look in v2.1 (the new stuff is highlighted in red):
    upload_2019-6-12_15-54-28.png

    upload_2019-6-12_15-54-57.png
     
    Last edited: Jun 12, 2019
    OCASM, Lex4art, ceebeee and 3 others like this.
  44. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    781
    Happy to hear about all these improvements! Take as much time as you need to implement cached shadows, I'm looking forward to using them in the future. :)
     
    tatoforever likes this.
  45. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    65
    That's huge!

    I'm really waiting for Primitive Shadows. Because my game is struggling from realtime ones)

    Here's the first prototype scene of our future cyberpunk project "Si-Q!" we've been able to make in six days. (p.s: don't look at these jerky AI dolls :D)


    As you can see, even with this small amount of shadowed Spot lights, game performance goes down a lot. (Around 20-25 fps on GT 740m. Video is recorded smoother than it plays for some reason )

    Really want to play with Primitives in there, and see if they can make my high performance dreams come true)
     
    tatoforever likes this.
  46. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    @alternativevisual
    Primitive Shadows are mostly targeted and dynamic props and characters, is not a full scene shadows replacement. What you probably need is Shadows Cache! ;)
    PS: Can't see your video, it says Unavailable.
    Cheers,
     
  47. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    65
    Isn't Shadows Cache a static objects related? Cause i want to make a fully destructible scene without statics marking, would i able to use that?
    And yea, i know that Primitive Shadows is not a full one click replacement, but i want to setup them for all walls, props and characters)

    p.s: my bad, fixed video access
     
  48. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    Are you profiling your frame times? You know the cause of the slow down?
    For your game I would reduce the NGSS sampling to around 8, you don't need very detailed shadows, they just need to look very soft from distance. ;)
     
  49. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    65
    I'm actually using 4 samples and lowest resolution in there :confused:

    Here's a test in editor:
    - Hard Shadows (No PCSS): 5ms on deferred rendering + 2ms shadowmap prepare (CPU profile). Unstable 40 fps
    - No Shadows: 1-2ms on Opaque rendering. Smooth 70-80 fps

    In the scene i'm using GPU instancing for environment, so everything is batched greatly. +Deferred rendering allows to use lots of lights without much of a cost

    Test in build:
    - No Shadows: Solid 60 frames per second
    - Lowest possible shadows: Laggy 35-40fps

    My old laptop GPU just can't handle shadows, and that's it. Will Primitives save me in this situation? :)
     
  50. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,889
    Alright so that's 7ms, where's the rest? :p
    Primitive Shadows can help you yes. It will probably save you a good amount of bandwith if you smartly combine it with shadowmaps.
    How is that your test in editor is the same as in build?