Search Unity

[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. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Upcoming update,
    Directional shadows improvements are much much better in last version. No more cascade blending issues or noise.
    End of pseudo compatibility with older versions, new version requires at least Unity 5.6.0. Still working on VR update with ContactShadows but everything else still on target for this week submission.
    I've also separated Directional Shadows from Spot/Point shadows code (in case you want only to use NGSS Directional Shadows). You can now just install the package and just drop the Directional shadow replacement in your Graphics Menu. :)
    PS: Unity 2017 compatibility will probably won't make it to this week update (crossing fingers).
     
    Lex4art likes this.
  2. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Our project is not only in VR, but also in 2017.1.0b9. NGSS has already become a cornerstone for the look of our scenes and I'm very much looking forward to the update. Thanks again for all your hard work, you are single-handedly fixing shadows in Unity :)
     
    tatoforever likes this.
  3. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix
    Forgot to mention that improvement to directional also includes Shadows Projection. It now works with any projection type, any cascade number. Noise won't be a problem anymore.
    PS: Will do my best to finish 2017 update this week. Almost 5am still working. ^^
     
    Lex4art and buttmatrix like this.
  4. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    561
    Excellent.
    btw, I was using 2017.1 here. Sadly, the camera component didn't work in the build. I guess you are already aware on this.
    Two more :p
    off:

    NGSS OFF 2.jpg

    on:

    NGSS ON 2.jpg

    Regards
     
    Voodoo_ZA and tatoforever like this.
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Voodoo_ZA likes this.
  6. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Improvements to directional shadows (PCSS and PCF).
    Only 12 samplers (extremely cheap to compute but remains good visually):



    I'm re-ordering pre-computed sampling disks (this will add more quality for free).
    A small video coming today.
     
    Last edited: Jun 28, 2017
    Invertex, chiapet1021, ZJP and 7 others like this.
  7. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    You can see smooth transitions between shadow cascades at the end of the video:


    With this new version you can say bye to shadow acne with PCSS! :)
     
    Last edited: Jun 28, 2017
  8. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    What is this banding? (I've increased the contrast and brightness so you can see where the banding lies)

    maybe cascade splits + directional light bias?

    Capture.PNG Capture2.PNG
     
  9. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    250
    dl pcss is coming for 1.x right?
     
  10. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
  11. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix
    That's not shadow banding, that's poor quality video recording. :D
     
    buttmatrix likes this.
  12. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    959
    Are you using the Unity Post Processing Effects camera script? I remember running into a similar issue with it causing banding if certain effects were used in conjunction... But it's fixed in newer versions of the asset.
     
  13. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    thank goodness

    It was probably just YouTube video compression, but you're right, LDR tonemapping effect can introduce banding if ordered incorrectly in the stack. Unity's new Post Processing Stack helps alleviate this by handling the draw order itself, but you can still run into issues if you use third party assets and place them incorrectly in the stack.
     
  14. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix
    Yes, besides the video capture which was already compressed + youtube video compression = you'll see color banding/compression everywhere.
    Here's some comparison images close and distant. Stable Fit projection now works better than CloseFit projection and provides an improved stable shadow patterns. Also cascade blending works smoothly (enabled by default), you won't see shadows being cut with cascades while moving the camera.
    Also the bias value is extremely low (0.015). I can even lower and shadows acne still won't be visible because how the PCSS algorithm works (it rejects pixels that aren't blocking the receiver so it's immediately fully lit = no acne).
    Disclaimer, visible aliasing (could make some eyes bleed):





    Note: Linear workflow, no post-effects.
     
  15. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    187
    Theoretical question: with new render loops in Unity 2017+ is it possible to set resolution of the shadowmaps above 1024px on "Very High"? It's hilariously low for 2017 year (as I remember - these shadow resolution limits were set in Unity 3.0 and they weren't updated since then). Contact shadows + PCSS are helping, but even this can't hide low-res shadows, especially for the large distance 500m~1500m were each cascade stretched on larger part of the scene.
     
    tatoforever likes this.
  16. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @Lex4art
    ScriptableRenderPipeline allows you to create your own renderers only. But you can modify the shadowing system that are created with (If there's any of course).
    In fact, the reason why shadows looks really low-res with larges distances is that it have to cover more area within the same shadowmap texture and once one visible screen pixel is smaller than one texel from the shadowmap then you will start to see shadows artifacts (specially aliasing). You will never get perfect shadows with larges distances, at least not right now. Some sort of cheap real-time shadows such as ContactShadows with lot of filterings n your shadowmaps will always be a good companion.

    The future of Directional shadows is really a mixture of shadowmapping and raytraced/raymatched (beyond just contact shadows). I'm actively researching this area a lot and it's looking very bright. ;)
    Good news is that new version of NGSS, Directional Shadows improves a lot visual quality and if you have the GPU power you can set quality bar a lot higher, up to (but not limited) to 64 samplers per frag.
     
    Last edited: Jun 29, 2017
    OCASM, Lex4art and Invertex like this.
  17. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I have accumulated many assets over the years, but NGSS is by far my favorite. This asset really should by $60+, but that's not my decision. People like @tatoforever and Adam Goodrich really set the bar for what the Asset Store should be about. Waiting to drop a review when VR and 2017.x are ready, but I'd do it twice if I could. Thx again.
     
    tatoforever likes this.
  18. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix
    There's nothing more satisfying than create tools for people and make them happy. It's the same feeling as create a game and make people smile but in a smaller scale. :D
    NGSS is just the very beginning. I will push shadows visuals and performance to new levels. :)
     
    ZJP and alternativevisual like this.
  19. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    VR Single-Pass Stereo support (Linear workflow, no post-processing, jpg):

    PS: Finalizing NGSS compatibility with Unity 2017.1.
     
    brisingre, one_one and Invertex like this.
  20. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    ^where's the 'love' button?
     
    macdude2 and tatoforever like this.
  21. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Ok folks, so I've finished writing compatibility with Unity 2017.1f1 and found out that Unity broke cascade blending by changing the sampling type of native shadowmaps. So I've temporary disabled cascade blending in Unity 2017 till they solve the issue. I've already spoked out the issue in the Closed Beta group.
    In the mean time, I'll try to implement a hackysh workaround but without proper texture sampling it will be more "hiding artifacts with more artifacts" scenario. No promise on that. :oops:
    Here's is a sneak peak at cascade blending On/Off:



    I'll finish documentation tonight and submit to the Store asap.
    PS: You can start sending email pre-requests right now. If if your first time requesting early access please don't forget your invoice number. :)
     
    Last edited: Jul 1, 2017
  22. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    294
    am having some issues with the asset.. am using unity 5.6.1 the editor on mac os , target platform is android.

    in editor.. it only works on defered rendering.. i tried forward but i don't see any change in shadows..

    i tried building a build.. and i got many shaders errors related to probuilder shader + multiple ones from .cginc
     
  23. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @mangax,
    There's an issue with replacement shadows on mobile where Unity can't find replacement shadows and put default ones (even if it's been correctly set). This is not related to NGSS but any replacement shadows in general. The issue have been reproduced by Unity and it will be soon fixed.
     
  24. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    @tatoforever Please tell me if this is the correct setup:
    1. NGSS_ContactShadows should be applied to main camera NGSS_ContactShadows.cs component
    2. NGSS_Directional shader should be set in Graphics settings, Screen-Space Shadows shader drop down menu; or, should it be set to Built-in shader?
    Docs indicate NGSS_Directional.cs should disappear after being applied, but I am not experiencing this behavior.

    I assume this is the cascade issue you were referring to (see attached)?
    Capture2.PNG
     
    Last edited: Jul 1, 2017
  25. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix,
    NGSS_Directional must be added to your directional lights in your scenes (it will setup everything under the hood automatically).
    If you don't want Directional PCSS, just remove it from the shader options but leave the NGSS_Directional.cs in your light. I'm adding a small note to Documentation so people won't get confused.
    And for your image, if you enable cascade blending shadows in 2017 you'll get semi-transparent directional shadows at cascade intersections. That's why it's disabled by default in 2017 (till they fix it).
     
    Last edited: Jul 1, 2017
  26. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Doesn't seem to be working; I'm probably missing something(?)
    Capture4.PNG Capture5.PNG Capture6.PNG
     
  27. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix,
    - Set shadows projection to StableFit (enable all 4 cascades for better quality).
    - Enable 32bits shadowmaps, this gives better shadow precision in Unity 2017 (Graphics Settings Option: "Prefer 32 bits shadowmaps").
    - Add the NGSS_Directional.cs component to your directional light and hit play.
    PS: Don't enable cascade blending in Unity 2017 or your shadows will fade out.
     
  28. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Wait,
    What's your target platform? If it's set to mobile it won't work. Unity replaces custom directional shadows with internal default shadows when platform is set to mobile. This is a known issue and it's being fixed by Unity right now.
     
  29. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Yeah, target platform is set to Windows, prefer 32 bit is enabled. You can see from the images in the above post, the filtering does not seem to be taking place. More importantly, the strength slider on the directional light does not effect any change, whatsoever. Really not sure where the issue is. What Unity version was this tested with?
     
  30. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Unity 2017.1.0f1 is the release candidate version, I'm testing on that same version, but deleting the subshaders did not make a difference. Is it something in the NGSS_Directional.cs? As I mentioned, the docs indicate that script should disappear after a success log, but that did not happen, indicating (to me, at least) that perhaps something was wrong(?)
     
  31. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @buttmatrix
    That's not the correct doc, I'll send you one with the latest changes.
    Try to re-import to a new scene it should works.
     
    Last edited: Jul 2, 2017
    buttmatrix likes this.
  32. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    294
    thanks for your support,

    in which version it has been fixed?
    also i have 32 bit disabled in build settings.. will this cause issues?
     
  33. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    73
    Something goes wrong :confused:
     

    Attached Files:

  34. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Are you using the pre-release?
     
  35. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    73
    Yea
     
  36. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Yeah, there seems to be some sort of quality discrepancy from the previous release. The banding you're seeing is probably the 'bias' setting on your directional light; or, whether you've chosen stable vs close fit shadow projection in the quality settings. However, the dramatic filtering you are seeing on the long shadow in your first image, seems to be another matter entirely.

    From what I've seen, the filtering seems to be applied based on the distance of the object to the directional light, as well as the height of the shadow casting object to any shadow receiving object, but it does so in a coarse manner(?) Whereas before I was getting fairly even shadow filtering on all objects - which was nice - now, objects seem to receive filtering in a functional way that I don't completely understand.
     
    Last edited: Jul 2, 2017
  37. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    That's how PCSS works and that's also how shadows behave in real life. It tends to smooth when caster and receiver distance are larges and harden when caster and receiver distances are short. There's also a performance function that reject pixels if they are not occluded (this sometimes can create bandings artifacts if your bias is set too low). You should always set your bias larger than default (0.05) if you have softer shadows. With shadows being hard you can lower it.
    Also, adjust cascade distances so blending between cascade is visible only at far ranges. Or turn off cascade shadows and set shadows projection to CloseFit.
    PS: PCSS is by default turned on, you can disable it on the shader if you just want normal soft-shadows (as in previous versions).
     
    Last edited: Jul 3, 2017
  38. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @mangax,
    You want to enable 32 bit depth buffer if you are using directional shadows with long range distances (larger than 150units). This grounds better shadows by having more close and far range precision.
     
    Last edited: Jul 3, 2017
    buttmatrix likes this.
  39. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @N3ON47
    In your images, bias looks to be totally turned off (Zero). You will never have perfect shadows specially if bias is off. Depending on how soft are your shadows we recommend default bias settings (bias = between 0.05 and 0.25, normal bias between 0.4 and 1.5), but not off or you'll have artifacts everywhere.
    If bias is not zero it should give you this results.
    PCSS soft-shadows (Enabled by default):


    And if PCSS is turned off it should give you this (PCF soft-shadows):


    PS:
    If you want more quality, you can enable 32 and 64 sampling on the shader. It's explained in the documentation.
     
    Last edited: Jul 3, 2017
    buttmatrix likes this.
  40. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Folks,
    I'm sending the current pre-realese version (v1.4) for review tomorrow morning. So pre-release users if you have any issue or think something should be in certain way (defaults settings for example) do let me know before I submit to the store.
    Then I will focus the rest of 1.x cycle on visuals/performance improvements for currents filters (PCF/PCSS).
    I'm also doing some research on spherical cascade blending as the default built-in cascade blending (linear) is basic and don't work with StableFit projection. Plus Unity introduced a new bug in v2017 that prevent proper cascade blending with any projection or cascade number. This improvement will be part of 1.x cycle too.

    Besides, I'm experimenting with new shadows algorithms (ESM, VSM, EVSM, Projected, Capsule shadows, and what not). Most of them are fairly easy to implement but tricky to integrate within the current built-in renderer as I don't have access to it's sources. For example, even if know how to encode Variance Shadows maps (which is a simple algorithm in a RF32GF32 texture) I cannot do it as the texture type is hardcoded within Unity buil-tin renderer, so I cannot implement on it. Once default Unity renderer will be finished in Scriptable Render Pipeline and replace the old one, then by that time NGSS 2.0 will be ready to be released with new shiny shadows algorithms. In the mean time, I will tease you guys and make your mouth melt in joy. :D
     
  41. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    +1 for capsule shadows
     
    OCASM and tatoforever like this.
  42. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    271
    Capsule shadows are awesome! I really enjoyed using them un UE4. This technique can do marvelous things when used right
     
    tatoforever likes this.
  43. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Projected Shadows are also mega awesome and ultra cheap, looks really similar to VSM.
    If you remember the old Unreal Engine (1,2,3) that's how they did shadows back in that time.
    This is what we implemented for our mobile game and runs fast as fak. So it may probable be back in NGSS 2.0. ;)
     
    OCASM, buttmatrix, punk and 2 others like this.
  44. ncgreco

    ncgreco

    Joined:
    Mar 1, 2016
    Posts:
    11
    Any idea what this is caused by?

    Shader error in 'Standard': Invalid const register num: 32. Max allowed is 31. at /Applications/Unity/Editor/Data/CGIncludes/UnityShadowLibrary.cginc(195) (on d3d9)

    The cginc it's referring to is the one I imported from this package.

    I'm getting that error each time I try to compile now. I've had to switch to Deferred Rendering not sure if that had anything to do with it.
     
  45. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @ncgreco,
    Remove DX9 from your target platform. DX9 sm2 have limitations. If you target DX9 devices make sure you only runs SM3 versions of your shaders if you are not targeting such platform.
     
  46. ncgreco

    ncgreco

    Joined:
    Mar 1, 2016
    Posts:
    11
    How would I go about all of that. I can remove DX9 from target platforms but idk if I really want to do that. I had all of this working just yesterday.


    EDIT: Just removed DX9 from target platforms and the problem still persists...I'm clueless right now. This was seriously working for over 3 weeks and now suddenly breaks....

    I've started brand new projects, and the same NullReferenceException comes up over and over again.


    NullReferenceException
    at (wrapper managed-to-native) UnityEngine.Material:Internal_CreateWithShader (UnityEngine.Material,UnityEngine.Shader)
    at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00009] in C:\buildslave\unity\build\artifacts\generated\common\runtime\ShaderBindings.gen.cs:259
    at NGSS_ContactShadows.get_mMaterial () [0x0001e] in D:\MyFolder\Something\Assets\Psychose Interactive\NGSS\NGSS_ContactShadows.cs:50
    at NGSS_ContactShadows.Init () [0x000a5] in D:\MyFolder\Something\Assets\Psychose Interactive\NGSS\NGSS_ContactShadows.cs:106
    at NGSS_ContactShadows.OnEnable () [0x00013] in D:\MyFolder\Something\Assets\Psychose Interactive\NGSS\NGSS_ContactShadows.cs:118


    Granted this is all when I run a Development Build I see this all happen. Launching in the editor is fine. I can pretend to not see the error while not running a development build but seriously what gives here?
     
    Last edited: Jul 4, 2017
  47. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    @ncgreco
    Yes, that error is due to Unity returning a null shader with Shader.Find command.
    You either need to manually provide the shader without using that command or just send me a PM we already got NGSS v1.4 with the workaround implemented.
     
  48. ncgreco

    ncgreco

    Joined:
    Mar 1, 2016
    Posts:
    11
    Good EFFING GRIEF,

    I swear more issues around "Well if it ain't in the Resources folder...it ain't in the build...trolololololol"

    I just moved the NGSS_ContactShadows into Resources/Hidden and no more NullReferenceExceptions at least. Still one final error


    Shader error in 'NGSS_ContactShadows': invalid input semantic 'POSITION': Legal indices are in [1,15] invalid ps_3_0 input semantic 'POSITION' invalid input semantic 'POSITION': Legal indices are in [1,15] invalid ps_3_0 input semantic 'POSITION' at line 27 (on d3d9)

    Idk how serious this one is, but it seems to just be working without throwing any exceptions...for now.
     
  49. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,964
    Remove DX9 from your target platform. If already done ignore that message.
     
  50. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    73
    Bias is not disabled :( I will test it later in 5.6.2p1
     
    tatoforever likes this.
unityunity