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. lukedarling

    lukedarling

    Joined:
    Mar 27, 2017
    Posts:
    5
    Any update on this?
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm having strange noise issues. See from :26 seconds on in my video:

     
  3. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    what unity version, j/c?
     
  4. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    5.6.2p1
     
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @magique
    Can you try setting ContactShadows properties to these settings (in this order):
    soft shadows 1
    shadows distance 2
    Shadow fade 1
    ray with 0.1
    ray samples 64
    And we will take it from there.
     
  6. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Same result. See noise in following image.

    upload_2017-7-4_13-11-39.png

    And if I turn off the contact shadows:

    upload_2017-7-4_13-12-43.png
     
  7. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Also, I am using latest asset store version of NGSS. I saw some talk of a pre-release version. I don't have that.
     
  8. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @magique
    Hard to see in your images but is your terrain casting shadows (from directional light)? It's recommended to cast shadows.
     
    Last edited: Jul 4, 2017
    hopeful likes this.
  9. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Yes, terrain is set to cast Shadows.
     
  10. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @magique
    Can you please write to support and provide a small scene with that terrain. Only the terrain would be enough.
    I'll analyze it that get back to you through.
    Regards,
     
  11. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I would have to remove everything else from the project except the terrain. Is that what you want?
     
    tatoforever likes this.
  12. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Not your project,
    For your testcase I would need only two files, your terrain data and a stripped out version of your scene (containing only basic stuff).
    First clone that scene, then remove everything except your main camera, lights and terrain (remove any non default components on them). Save it.
    Then select that scene and the terrain data (click on the terrain component to know where it's terrain data is located in your project) and create a package (right click - export package) and send it to support email.
    Regards,
     
  13. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    OK. It's a scene with 4 terrains, but I can export them all. It'll take a little while to put it all together.
     
  14. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    @tatoforever OK, I sent an e-mail to support with a link to the package.
     
    tatoforever likes this.
  15. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    it is the exact same problem i mentioned some posts before the angle of the terrain at that postition is very flat to the angle of the direct light.
     
  16. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    Hi

    After update to 1.4 (.1?) I'm getting tons of acne on my terrain (I'm not using contact shadows)
    Here's how it looks:
    upload_2017-7-5_16-9-39.png

    What I'm doing wrong? :)

    Thanks!
     
  17. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Sterner,
    Change your shadows projection to StableFit and adjust bias settings with the new projection.
     
  18. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    I've did that right after update - changed to Stable Fit and set biases to 0.05 and 0.4 accordingly. Even more - I've tried setting them to different values, but that didn't change the result at all. Also I've noticed weird issue - shadows from main character are soft only if they are close to penumbra of other shadows otherwise they look like Unity Hard Shadows
     
  19. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I think I know what you are talking about, can you post a screenshot highlighting this issue? I'd like to see if it was the same thing I was referring to in an earlier post.
     
  20. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Can you provide a small video showing how you set your bias values and see how it looks on your scene?
    Or better, if you can provide a small project showing the issue and send to support email that would be awesome.
    That's how shadows behaves in real life, the larger the distance between caster and receiver the softer they are. The shorter the distance between caster/receiver the harder they are. The only way you will have uniform soft-shadows is with indirect lighting but directional light is not an indirect light is direct 100%. I'm working on indirect shadows for NGSS 2.0.
    If you don't want such behavior, you can turn off PCSS filtering by commenting the line 243 in NGSS_Directional.shader.
    Regards,
     
  21. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    There is no denying that this is true, but it seems like some obejcts are actually getting hard shadows that are "hard" to the point of aliasing.

    I said I'd put some images together, so I'll try to do that asap.

    I get that we can avoid this altogether by just commenting the code, but I'd like to diagnose the problem clearly to make sure we are on the same page.
     
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    The aliasing is due to low shadowmap resolution, this can only be avoided by softening shadows. I can also clamp to a minimum soft value to avoid the shadows being too hard (and show how aliased they are) even if caster/receiver distance is zero. If that what you want?
    But all in all PCSS algorithm works like in real life (harder when caster/receiver distance is short, softer when caster/receiver distance is large). Here's an example in GTA 5 (PCSS):

    You can see tree leaves being very soft because of large distance and the character legs shadows hard because of the shorter distance it's being casted into ground.
    PS: As for the bias issue, perhaps it's being triggered only with your current setup, I would like to know more(example scenes/video/images) to provide a fix if it's a bug.
     
    Last edited: Jul 6, 2017
    buttmatrix likes this.
  23. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Another thing that makes Unity directional shadows look bad (specially very aliased) is how basic they are. It's simple PSSM with pre-defined depth distribution, this not only waste tons of cycles with invisible geometry being rendered in light depth but also wastes unused memory. Logarithmic distributed depth or the likes can produces better directional cascades where cascades transitions aren't visible and provides very good distant shadows, unnoticeable cascade transitions and they are faster to compute while taking significantly less memory.
    I'm also working on this for NGSS v1.x alongside more visual and speed improvement on the current filtering.
     
    Last edited: Jul 5, 2017
    Lex4art and NeatWolf like this.
  24. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    i don't remember well, but i think there is a away to export package or current scene without exporting eveything in project..
     
  25. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    Yes, +1 for this option - ancient 1024px of "Very high resolution" in Unity needs special treatment, if possible as an option like a slider "minimum shadow blurring" or something XD ...

    Yes, pick scene file itself in project view and hit "Export selected" - all stuff related to this scene will be exported ).
     
  26. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Lex4art
    My goal is to provide quality shadows as those seen in GTA V PCSS shot above (at least). But yeah that would be hard to achieve with current tiny shadowmaps (I think they go up to 2048 for all splits and get's lower on different platforms). That's why NGSS 2.0 does not use Unity depthmaps but instead I render myself all shadow depths, so user can freely chose the desired size (mobile upto 8K and consoles/desktop up to 16K). It's an atlas shadowmap. One atlas for directional light, and one atlas for all indoor lights.
     
    buttmatrix and Lex4art like this.
  27. Sterner

    Sterner

    Joined:
    Nov 11, 2012
    Posts:
    33
    I do understand how they should work and how they work in real life )))
    I'm saying that they do behave correct if my shadow caster (character) stays in penumbra of other shadow caster. If no shadow casters present in front of character his shadows do not work correctly

    I'll prepare small video and separate project if issue will remain there

    Also sometimes shadows from big objects are cut and bias values do not change that

    UPDATE: videos are sent to support
     
    Last edited: Jul 6, 2017
    tatoforever likes this.
  28. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I spent some time adjusting the settings in NGSSDirectional.cs and UnityShadowLibrary.cginc and arrived at the following images to summarize my observations:

    The idea of PCSS is spot-on, but I am unable to get the effect to play nicely with the settings available in NGSSContactShadows.cs (see PCSS_Poisson_32). However, disabling PCSS - and leaving the contact shadows settings exactly the same, using Poission_32 - you get incredibly soft, albeit physically inaccurate shadows (see attached NOPCSS_Poisson_32). I suppose it is a matter of opinion which you prefer, but the latter image contains incredibly soft shadows, which are very pleasing to my eye.

    It is possible there is a PCSS configuration that will produce similar results in the second image, and I'm simply misunderstanding how to best use the plug-in. I think enabling a minimum 'softness', as was mentioned above, is probably a reasonable idea, because Unity hard shadows alias quite a bit - you can see Unity hard shadows on the 5_10_scaleman in the first image, and Unity soft shadows in the third image.

    PCSS_Poisson_32.png NOPCSS_Poisson_32.png Screenshot (25).png
     
    Last edited: Jul 6, 2017
    Lex4art and tatoforever like this.
  29. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @buttmatrix
    I'm doing some tests with the minimum soft shadows in PCSS filter, could you please email support to get that version and try out?
    Regards,
     
  30. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    I'm btw optimizing the crap out of NGSS. In the next version, you'll have ~128 taps visuals with only ~32 samplers, which means, it will be hellish soft and almost no visible artifacts. Preview images/videos soon. :)
     
    magique, AcidArrow, NeatWolf and 4 others like this.
  31. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    @tatoforever

    thanks for your support, just side note.. am mainly a mobile developer..
    so i hope all the new enhancement and additions should consider performance on mobile..

    am sure that on long term there will many requests by users.. which might end up making the asset complex overtime or might have some effect on performance.. so i hope at one stage in future in case that the performance on mobile degraded..you consider splitting high end devices (PC/consoles) from mobile (low end devices)..
     
    tatoforever likes this.
  32. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Latest version on assetstore doesn't work, I believe it is not changing the graphics settings custom screenspace shadows or something... !?
     
    Last edited: Jul 7, 2017
  33. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @olavrv
    Few things changed on last version. They are all written in the documentation.
    But basically, you no longer set Directional shadows through Graphics menu, instead you drop a script onto your directional light and it does everything for you.
    If you still have trouble after setup, please email support, I'll be online for the rest of the day till tomorrow morning. :D
     
    Last edited: Jul 7, 2017
  34. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @mangax,
    Fortunately, what we consider low quality shadows are top quality shadows on mobile and it will remains like that for a while. Low = mobile, mid = consoles, high = desktop.
    Overtime with newer versions of NGSS we will drop obsolete/older filters by replacing with new ones, specially if they look similar. But all in all, I want to keep NGSS setup as simple as possible. It will remain a shadowing only library.
     
  35. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Hi, I have it setup correctly (with script on light). If I disable the part in your script that sets it automatically, and change the screen space shadow shader manually in graphics settings - it works. But it seems that when changing this at runtime it doesn't work (at least in two latest patches for Unity 5.6 (haven't testet latest NGS on older Unity versions)

    PS: I also get shadow noise on skinned meshes (only when NGS is enabled). The noise appears in transition between light and shadows (soft shadow area).

    PS2: NGS is fantastic! :D
     
  36. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @olavrv,
    Can you share some images or videos of the noise you are having?
    Regards,
     
    hopeful likes this.
  37. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Folks,
    I got a new version that let your chose the minimum and maximum soft-shadows values with PCSS. Both values are independent from the Strength value which act as a global softness. Demonstration:
    https://s3.amazonaws.com/uploads.hipchat.com/43289/288706/YwYK99bH5mK4DeL/Directional Improvement2.zip
    Next thing I'm tackling is the acne issue introduced in version 1.4. Would be awesome if I can use some of your scenes to test out. Email support if you want to help out or if you want to try out the new additions to Directional (min/max softness) shadows.
    Regards,
     
    Last edited: Jul 8, 2017
    pixelsteam, Lex4art and buttmatrix like this.
  38. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I don't think the min value of NGSS_PCSS_FILTER_DIR_MIN 0.05 can be improved upon: anything smaller introduces aliasing, anything larger seems unrealistic.
     
  39. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    This will be useful for large-scale shadows (500+ meters visibility distance) to hide huge shadow pixels (if I'm understanding this right). For low-res shadows (like "very low/medium") with very large pixels it also will be useful to blur them stronger...
     
    Last edited: Jul 8, 2017
  40. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @buttmatrix,
    Aliasing comes from low shadowmap resolutions. The only way to hide it is by softening (multi-sampling) the shadows. You can't just hide aliasing without softening shadows, there's no other way around.
     
  41. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    I think what I mean to say is that you did a really good job with the default values of .05 and .125 for min and max, respectively. It looks great!
     
    tatoforever likes this.
  42. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    This screenshot is from the editor, but same at runtime
     

    Attached Files:

  43. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    I’m working on a minor update that will let you override the overall soft-ness of shadows (PCSS / PCF filters) and go higher that what’s default (on top of being able to chose min and max soft-shadows in PCSS).
    Keep always in mind that the softer the shadows the more visible acne will be. This is side effect of PCF filtering, you’ll have to tweak bias in consequence.
     
    olavrv likes this.
  44. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @olavrv
    Can you pack that project and send it out to support so we can take a closer look to it. Shadows artifacts are always scene dependent but there's also some chances we've introduced some sort of erroneous acne bias in v1.4. We want to make sure and make proper fix or improvements but it's always better with user-end real scenes. :)
     
    buttmatrix likes this.
  45. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Is there a perf difference for PCSS vs. PCF filters in v1.4, there seems to be.

    Is there any way to leverage Bayer matrix dithering or blue noise in NGSS? (j/c)
     
  46. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @buttmatrix
    There's a difference but not really noticeable. PCSS skip PCF if the fragment is not fully lit. If the blocker is occluding the pixel then we can also skip PCF because the pixel is in a shadowed area (this small improvement is also coming in next week minor update). So all in all, what we are really interested is not in fully lit or fully shadowed areas but instead in penumbrae areas. :D
    I'm right now experimenting with edge depth dilatation and optimized PCF disks, it should improve performance by at least 2-3 times (if not more) with both PCF and PCSS. This will allow me to do a lot more taps for free and makes shadows look way better than it is with larger ranges of softness while being almost (if not totally) noise free.

    PS: Various sort of dithering are also on my visual/performance improvement list of thing to do yes. ;)
     
    hopeful and Lex4art like this.
  47. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    i havn't update my project with your newest version.. but am eager to do so and see how it would look on mobile :)

    looking at your asset currently.. i think unity devs should buy/integrate your asset into unity.. such feature should be available within unity lighting options by default.. the current lighting shadow settings now really feels outdated when confornted by your shadow implementation!

    maybe they should hire you ;)
     
    tatoforever, Seith and buttmatrix like this.
  48. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Syberam
    Unfortunately no. There's no way to make shadows artificially darker beyond what ambient settings are set to. In general shadows are just absence of direct light. As soon as there's no direct lighting contribution, well the resulting darkness color will be a full contribution of ambient lighting. If you need darker shadows, make your ambient settings darker.
    If your game has a non-realistic style and requires specific shadow coloring, this can be done through various means eg: intercepting shadows attenuation functions in your custom shader and override final output color. I recently wrote a custom shadows drawer for a client with similar settings.
     
    Syberam likes this.
  49. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    I've also had problems with shadows not being dark enough. I left a detailed answer in the Hx Volumetric Lighting thread. In short, you won't be able to fix them with another asset. If it's another asset washing them out you can try to correct that with tonemapping, or you can make them darker by turning off a bunch of different unity features that add extra light to areas that are supposedly in shadow. (This is why it's still so bright when you have no lights in your scene -- everything should be totally black in a world with no lights in it, but that's far from the case with default Unity settings.)

    Just gonna throw this out there: colored shadows would be a killer feature for your forward+ renderer.
     
    Syberam likes this.
  50. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    If you need different ambient lighting on different objects, you can't use Unity's ambient lighting. You'll have to write a custom shader, fortunately not a super complicated one, I don't think. Basically, you want it to ignore Unity's ambient lighting, calculate a new ambient lighting color based on the angle of the face and some material properties you give it, and add that color to whatever other light it's receiving.

    I can't tell you the exact syntax to write this shader by hand. The documentation should be enough to get you there eventually. If you want to save some pain, Amplify Shader Editor's really good. I'm confident it wouldn't be too much work at all to set up something like this with ASE.
     
    tatoforever and Syberam like this.