Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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. Teh_Lemon

    Teh_Lemon

    Joined:
    May 12, 2015
    Posts:
    17
    Hey. The directional shadows seem to be forcing 4 cascades/stable fit. Is this intentional?
    Btw that "game's contact shadows being overlaid onto the scene view" bug went away when I updated to U2017.
     
  2. LandHT

    LandHT

    Joined:
    Feb 3, 2017
    Posts:
    84
    • How's the performance in mobile?
    • Is this compatible with GLES 2.0?
    • Will baked shadows match real time shadows? Cause unity's default is soft baked shadows against jagged real time shadows which differ to much for my taste.
     
    Last edited: Jul 27, 2017
  3. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    75
    Can't wait for this update! :)

    Notebook Asus K56CB, HD+ 15'6 monitor, GT 740m, Intel Core i7-3537U 2.00 GHz, 6gb RAM

     
    tatoforever likes this.
  4. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Teh_Lemon
    Yes, it does it when you install the component in your light but afterwards you can set it back to what your game needs. I've removed this functionality in the next version.
    PS: ContactShadows got an update in the last version that fixed shadows artifacts. ;)
     
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @N3ON47
    Your computer is really in the low end range. You probably want to avoid as much point shadows as possible (no more than 3 or it will eat all your bandwidth). Did you tried using PCF instead of PCSS filtering on your point lights?
    PS: To enable PCF just set your shadows type to Hard.
     
  6. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @N3ON47
    Preview of editor twekable options for shadows:
    https://s3.amazonaws.com/uploads.hipchat.com/43289/288706/rY01Y8Soe9V3yFb/GlobalOptionsPreview.mov
    Sampling count still missing (adding as we speak) and then will do the same for Local lights (spot/point).
    Something to notice, setting sampling count on local lights through script globally will be problematic as Unity seems to ignore shader compile features in cginc files, so I'm looking into hackish ways to do it (passing global arrays)? This seems like a bug to me.

    And keep in mind those options are global, I don't have access to specific lights indexes within Unity rendering files so they apply to all lights. It's basically all you can do right now within NGSS shaders but through Editor.
     
    buttmatrix and Seneral like this.
  7. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    I think I have already written this at least two times in this thread but.... I really LOVE this asset! Are you also planning to release your custom renderer? Our game would really benefit from that, since the many lights we use are a performance killer...
    Here is some eye-candy by the way ;)
     
  8. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Ona-H
    Harold Halibut artistic direction is awesome. Love the stop motion feeling and the clay rendering adds a lot to the stop motion graphics. :D
    Yeah our custom renderer still in the heavy works and will be released in the future (hopefully 2017). :D
     
    magique and hopeful like this.
  9. LandHT

    LandHT

    Joined:
    Feb 3, 2017
    Posts:
    84
    Ah, thanks for replying my mail! Fast response :D

    I'm pretty much doomed until unity's solves the forward override bug cause my game is orthographic, so no deferred mode :/
     
    tatoforever likes this.
  10. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @LandHT
    Unfortunately there's no workaround for that. They didn't answer my last 4-5 emails on the bug case. :\
     
  11. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Folks
    Final directional options that will ship with this week update:
    https://s3.amazonaws.com/uploads.hipchat.com/43289/288706/7Q04nJ0KUHZADbM/DirectionalOptions.mov

    Keep in mind those are not per light options, they are global for all shadows (spot/point/directional). Fortunately you still have the Strength value on lights to customize the shadows soft-ness in a per light basis like before.

    Also did a small optimization on all PCSS blockesearch algorithms, making them 50% faster than previous versions. :)

    PS: It should be ready tomorrow.
     
  12. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    With your system, I would recommend to stay away from PCSS on point lights (use PCF only). Or simply limit it's use, no more than two visible at the time on the screen (enable and disable them smartly). Or even, switch to PCSS only to the closest point light on the screen leaving further ones on PCF.
     
  13. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    So here you can see what appears to be normal shadow biasing. In this case there is no lambert term so its only the shadow map doing work.
    AbzuRendering.png

    Here is another material that appears to fade its shadow in over a small distance.
    AbzuRendering-2.png

    My guess is it works like this:
    AbzuRendering-3.png

    Where when it samples the shadow map instead of switching from lit to shadowed instantly, it fades over some distance defined in the shader.

    I think it may fix these artifacts, which seam to be caused by that hard switching.
    AbzuRendering-5.png

    I spent some hours yesterday trying to get it to work but no luck. I think i'm misunderstanding how the shadow depth values are working. =<
     

    Attached Files:

  14. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Cynicat,
    I'm not sure to understand your problem. Bias is just an offset to the receiver (Z axis on light space) to avoid false self-shadowing (shadows acne). If you fade your bias you are looking for more shadows acne because you are putting closer your receiver and your z depth test.
    Your last image shows a common shadowmap problem (due to lack of depth precision).
     
  15. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Sorry i don't know how to explain it better =<.

    The artifact is actually based on the pixels of the shadow map though. if i lower the shadow resolution those artifacts get worse. Its because each pixel in the shadow map is at a different distance and can't be interpolated. It ends up looking like layers of shadow.

    I'm going to try to see if i can implement it on my own, then i can hopefully just show you the code for it.
     
  16. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Cynicat
    You are trying to fix the bias algorithm if I'm not mistaken? If so, there's multiple ways to do it. But it will require you more than just the shadow part. Some of those code requires receivers normals and other input data.
    Feel free to email me your scene with your bias implementation, I will give you a hand on that.
     
  17. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Woo! Got it working!
    Without Fade Bias:
    Fade Bias-2.png

    With Fade Bias:
    Fade Bias.png

    Exact same settings for both images. Just fade bias added.

    Only code i changed was sampling shadows. In this case i only did it for point light but it should work for all lights hopefully.
    Fade Bias-3.png

    i define fadeBias at the top of the function. Its just converting 0.1 meters into the lights 0-1 range.
    Fade Bias-4.png

    All this is in addition to a small standard bias. but this holds up better because even when you would get shadow acne its a lot fainter. it actually looks kinda ok even with 0 normal bias (though i still say you should use both)
     
    Last edited: Jul 28, 2017
  18. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Cynicat
    I see what you meant now. That's not bias, it's just interpolating a small value to fade shadows over light range. I've added it to the code, not sure if it will be enabled by default as I need to test it in all possible cases but it should make you happy thought. :cool::)
     
    buttmatrix and Cynicat like this.
  19. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Yeah sorry, wasn't sure how to explain what it does. Thanks for putting up with my overly long winded posts. Keep up the awesome! =3
     
  20. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hello @tatoforever
    great job! i've just updated and I got this issue:

    this happens if I start with hard shadows set up..
    if I start with soft and change into hard, it works and no errors..

    another thing is that seems that with soft shadows (PCSS) seems to have more fps than the hard shadows (PCF)...
    the fix of @Cynicat will be on the next release?

    regards
     
  21. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    after upgrading to latest store version i got around ~5 fps
    before i got around 100 fps
     
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @ghiboz
    I've already implemented though need more time to test them properly on spot/directional lights as they don't provide raw depth and we loss GPU free PCF 2*2 (on top of NGSS ones). But probably in this week update yes.

    @nbac,
    In the latest version, I accidentally defaulted to 64 samplers on point lights which makes it a bit heavier to render (specially on low end computers), this week update they are by defaulted back to 32 samplers.
     
  23. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Point lights are unique in Unity in that they are sampled by comparing the pixel distance to the shadow map distance in the shader. All others are doing hardware PCF; you pass the pixel position into the equivalent of a "tex2Dproj" and it spits out a "soft" shadow value. There's not a way I know of to get the actual shadow map distance value to fade with as the hardware PCF is enabled by setting a special texture type on the shadow map itself (I think?). In a more custom setup this is easier to do since you can just not set your render textures to be a ShadowMap type and thus it won't do this special handling for you.
     
    hopeful and Cynicat like this.
  24. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Thanks for the info. I was wondering why it was not working. Guess its time i rolled my own renderer. X3
     
    tatoforever likes this.
  25. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @bgolus,
    Exactly, with directional light is possible to some degree reusing the rawdepth access but again we lose the ability to get free bilinear PCF. So fixing one problem brings new one (different visible artifacts).^^
    I've implemented it but won't be enabled by default though.
    With inline sampling in 2017 will be possible but only if you have access to the shadowmaps texture formats and needs to define two samplers for that texture. But again, if you don't have access to the texture format (not possible with Unity renderer) won't be possible. Fortunately, with NGSS 2.0 it will be possible as I'm the one managing shadow textures and depth rendering. :D
     
    Last edited: Jul 29, 2017
    Cynicat likes this.
  26. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Last edited: Jul 29, 2017
    OCASM, buttmatrix, Lex4art and 5 others like this.
  27. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    tatoforever likes this.
  28. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267

    i have a pretty solid setup with a 1070 and 16 gig ram so ... :D
     
  29. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    my same config, and also for me the new update has a big drop of frames (in addition to the issue that the PCF is faster than the other :p)
     
  30. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    75
    First screenshot 1 PCSS point light - 7~ fps
    Second screenshot is 4 PCF lights - 50 fps

    P.S. Direction light PCSS works okay for me, likely
     
  31. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @N3ON47
    Never under estimate the power of point light soft-shadows. They can put any computer to it's knees. :cool: Specially with Unity, cubemap shadows is a bad idea (hard to filter, cube faces can't be culled, hard on memory, etc). Modern techniques just unfold all faces in an atlas and skip faces that do not cross the view frustrum. If you render to a cubemap, then you are stuck with all faces or nothing and needs to sample all 6 faces. :rolleyes:
    PS: I've accidentally defaulted to 64 samples in the last version, which makes it 128 samples for blocker and filter. I revert it back to how it was before last update.
     
    Last edited: Jul 29, 2017
  32. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Improvements to PointLight shadows filtering with new noise algorithm.
    Before (notice the noise jumping everywhere when the camera moves):
    https://s3.amazonaws.com/uploads.hi...6/psyZRGbN5cFQb1q/PointShadowsNoiseBefore.mov

    After (notice the noise mapping to screen pixels):
    https://s3.amazonaws.com/uploads.hipchat.com/43289/288706/qj2jybP9lgYTuCP/PointShadowsNoiseAfter.mov

    Improves quality so you can reduce sampling for free! Bye bye dancing noises. :cool:
    PS: Tested with 32 samples. Submission will happen tomorrow.
     
  33. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
  34. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @ceebeee


    Note sure why Unity call it 32 bits shadowmaps, those are 32bits depth buffers. -_-
     
    buttmatrix likes this.
  35. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    Ok, that's why I was confused. thanks.
     
    tatoforever likes this.
  36. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    tatoforever likes this.
  37. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Folks,
    I'm working on a secret massive screen space filter that will filter hundred of shadowed lights for free. Well not really free (almost). It will be the same cost as having one filtered light with plenty of hard shadowed lights but with the difference that they will all be super soft (PCF and PCSS).
    Coming on NGSS 2.0. ;)
    Preview videos coming soon. ;)
     
    Last edited: Jul 30, 2017
    Invertex, magique, Onat-H and 9 others like this.
  38. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    ^If there is an Asset Store developer award, it should go to you. Seriously, excellent work you're doing here.
     
  39. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    155
    This thread really puts me in a good mood in the morning. Fantastic job!

    By the way, I was wondering about something.
    I am using a transparent dome to make the clouds in my scene. This works just like a standard transparent shader. it can't receive shadows, but can project some "faked" semi transparent shadows using a dithering method.

    Here are 3 screenshots of a plane receiving these shadows. As you can see, your asset really improved the way it looks, with a shadow strenght of 1, especially compared to the 4th screenshot (strenght to 0, full hard shadows).



    I was wondering if there would be some improvement to expect on this side? It would be fantastic if we could have some badass transparent shadows coming from smoke/glasses using you asset! :)
     

    Attached Files:

  40. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    arnoob and Lex4art like this.
  41. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    155
    Actually, I was talking about shadows casted by transparent object, like in here : /https://forum.unity3d.com/threads/shadows-of-transparent-objects.278810/

    For smoke particles, or, like in my example, clouds, you can have a basic dithering. i wanted to know if you could see if you could make this particular kind of dithering better looking using your process? :)
     
    tatoforever likes this.
  42. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @arnoob
    Oh my bad, read it too fast. :D
    Yeah, I'm always looking into ways to improve current filtering while working on side secret sauce. I think some of you guys sent me a similar scene that I'll use to try out few things to improve dithering algorithms. :)
     
    arnoob and hopeful like this.
  43. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    155
    Well I can send you my dome if you want. The shader isn't some AAA stuff, but it's decent :)
     
  44. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @arnoob
    Np, go ahead and send it please. :)
    PS: Pack the shaders/models/etc and the scene into a package file.
     
  45. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Last edited: Aug 1, 2017
  46. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello, ngss work quite well on mobile but only in deferred mode, is there any plan for forward rendering knowing most of mobiles will use this render mode.

    or do i miss something? i m testing on android plateform with unity 2017.

    thanks
     
  47. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @toto2003
    Yes, it's a Unity bug. If platform is set to mobile and rendering is forward, Unity is unable to find the shadowmapping shader tag and then attributes a default directional shadows.
    It has been reported and reproduced a while back but they don't really seems to care about it. My last four messages to the QA guy never got answered back. :\
     
    arnoob and toto2003 like this.
  48. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    155
    Hi tatofever, I will make the package and put here (as well as on the unity subreddit) later when I come back from vacation.

    Your video looks really good! The framerate is impressive (what is your specs?). But I was wondering, where are the 72 shadow casters coming from? Could you elaborate a bit more? :)
     
  49. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @arnoob
    Main test rig is: iCore7700, 16GB ram and GTX1070
    The 72 casters comes from the point lights rendering multiple times the same object. Remember point lights shadows have 6 faces. An object, depending of his size, can be rendered multiple time if it's visible by multiple faces.
    So let's say 11 objects in my test scene multiply that 2 - 3 (each one visible by 2 or 3 faces) and then multiply that by 4 (four point lights where used in my test case) = gives around 72 shadow casters yeah.
    PS: One point light shadows is exactly the same as 6 spot light shadows. They are heavy yeah. ^^
     
    Last edited: Aug 2, 2017
  50. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Folks,
    New version is ready, features:
    - Stabilizing noise algorithm for all lights. Mapping samplers to screen space pixels avoids jumpy patterns when camera translates/rotates. Plus a static new one (read down below for more info).
    - Bias fade. Fades out shadows at penumbra edges to avoid blocky transitions between shadows and light. Also helps with bias as it's gets smoothly faded out. Works only with Point light shadows or Directional shadows (if PCSS is enabled). Credits to @Cynicat who provided initial tips. :)
    - Directional shadows now expose some of it's internal properties on it's component such as global softness, PCSS min/max softness, etc. You can tweak it at runtime without editing shaders. Spot/Point shadows global settings are harder to expose as it's not a shader file but an include file thus Shader features/compile does nothing to it. Still requires manual shader defines tweak if you want to enable/disable features on it.
    - Improved point-light shadows performance. Tweaked early bailout algorithm (make it a bit more aggressive) to cull out fragments more efficiently = faster to render.

    I would like to ask if you want to test before I submit to the store, specially the performance improvements on Point Shadows. Also let me know what you guys think about this new static noise pattern:

    https://s3.amazonaws.com/uploads.hipchat.com/43289/288706/1uhriyDBeZi7GEz/Static Noise patterns.mov
    Please email support to try the latest additions and the new noise filtering. :)
     
    Cynicat, Seneral, Lex4art and 2 others like this.