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

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    NGSS 2.0 logo.png





    directional shadows.png

    denoiser_pcss.png

    point shadows.png

    spot shadows.png

    Asset Store link: http://u3d.as/1qNz


    The next iteration of the smoothest and fastest dynamic soft-shadows solution for Unity is here. Easier to integrate, faster to render, prettier than previous versions! Featuring powerful new tools, shadowing algorithms, optimizations and user friendly self-descriptive light components to improve the quality of your scene lighting. NGSS is complete shadows package to skyrocket your projects quality to the next level!

    Shadows algorithms:
    A PCSS filter (Area-like soft-shadows) and a PCF filter (uniform soft-shadows). A powerful denoiser that skyrockets the base filters, acting as a separable filter and features screen space Contact Shadows with bilateral filtering and edge tolerance. Chose between white noise or dithering. Samplers are stabilized at screen-space thus the shadow samplers jitters less while being Temporal friendly.

    Optimizations:
    NGSS uses the least amount of sampling to filter out shadows while skipping fully lit or fully shadowed areas making it one of the fastest solution on the market for realistic penumbra shadows.

    Inspirations:
    NGSS features a ground-breaking combination of kernel filters mainly based on Monte Carlo. The result is a high quality smothered dynamic penumbra shadows similar to raytraced shadows with superior banding and aliasing removal, making extremely tiny shadowmaps look outstanding.

    The package:
    This new version comes with one Wizard tool to install NGSS internal shadow libraries and is one click to install and one click to uninstall. Both Local shadows and Directional shadows provides it's own libraries, they are independent from each other. NGSS provides shadow components to attach to your scene lights (all lights) that allow you to tweak shadow properties such as quality, softness opacity, etc at runtime.
    Finally, NGSS replaces Unity shadows libraries internally, this allow NGSS to behave the same way as Unity shadows while being compatible with any packages on the AssetStore that uses the Standard (built-in) renderer.

    Works locally by installing NGSS libraries or with remote cloud builds system by including the libraries directly into your shaders. Easy and quick setup.

    Compatible with VR, DX11, DX12, PS4, XB1, SWITCH, GLES3.0, Metal, Vulkan or equivalent/new APIs/Platforms. Requires a minimum of SM3.0 on supported APIs/platforms. Not compatible with DX9 and GLES1/2!
    Unity 5.6 up to 2019 (Built-in Renderer), HD & LW pipeline support coming in the future.

    Support:
    Stellar customer support. Custom inquiries and code modification for free. Most requests are answered almost instantly. Two years ago NGSS 1 launched, many updates and features where implemented since then resulting in lot of happy customers!
    For any question, issue, bug, custom inquiry, custom framework or renderer integration:
    You can use this forum thread, the support email: support@psychozinteractive.com or discord channel: https://discord.gg/jWEUXYw
     
    Last edited: Apr 14, 2020
  2. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    It looks great!! I will buy it if it works for iOS especially apple tv
     
  3. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    It works everywhere Unity support shadows because it uses Unity build-in shadowmaps. :)
     
  4. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Lars-Steenhoff
    If I remember correctly, Unity doesn't do any point/spot light shadows on mobile as a performance consideration (only for directional lights), so my solution won't work for those lights on mobile. If you need a custom lighting solution with any kind of soft-shadows for mobile, PM me please.
     
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I'm working out the documentation and preparing for AssetStore submission.
     
    Lex4art likes this.
  6. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I've put out a small video showcasing the shadowmap custom filtering, the video quality isn't that good (visible this time only point light shadows):

    NOTE: The rock on first post is casting dynamic shadows, not in this video. The idea was to showcase how nice this kind of shadows blend with high quality raytraced baked shadows.
     
    Last edited: Nov 16, 2016
  7. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @tatoforever That looks very nice! I have 2 question for you: what is the impact in terms of performance compared with default shadows? And what would you say are the drawbacks/limitations (if any)?
     
  8. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Seith,
    The filter is fast, faster than anything on the Asset Store, because it achieves better shadows smoothing and with no banding with few samplings and instructions (16 samplings in the images above). Compared to the default Build-in Unity Soft-Shadows is not really noticeable, hard to say.
    As for the limitations, I don't really see any drawback/limitation, it works anywhere Unity support shadows because it uses Unity shadows.
    Something to note: This filter don't do anything to Directional Shadows (only to point and spot shadows) and the reason is that Directional shadows already does a 5x5 PCF filtering plus screen-space rotated poison disk sampling. I'm doing something similar to that technique to unify the look of all shadows in Unity (with the dynamic adaptation of penumbra size based on caster-receiver distance).
    This technique is also faster than PCSS filtering, way way faster, because again, it requires less sampling and instructions.
    Your FPS doesn't change if you use this filter or default build-in soft-shadow filter. I'll see if I can record a video of it.
    Thanks for your interest. :)
    [EDIT] Nice game btw you got there.
     
    Last edited: Nov 16, 2016
    Lex4art likes this.
  9. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Seith,
    Some performance tests made today. I've used the same scene but all camera effects where disabled so there's no interference with the shadows performance.

    Video:
    https://s3.amazonaws.com/uploads.hipchat.com/43289/288706/KtKFUdv3oKoGMgW/SSFS filter test.mp4

    Video encoding eat a lot of CPU so here are images of the same test:





    As you can see it's hard to notice any performance degradation as there's probably none. Some times with the [SSFS] filter it goes even faster than no filter at all (hard shadows) as shown in the images above.
     
    Last edited: Nov 16, 2016
  10. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    Looks good, what are steps for setup? Just curious if it's compatible with the Alloy3 shader framework
     
  11. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    It's compatible with everything that support Unity shadows. The setup steps are as simple as to replace a "cginc" file in the Editor folder and optionally add a script anywhere to a GameObject to change the global soft-ness of the shadows. That all. :)
    PS: This shadows filter adjust the penumbra size of shadows automatically based on distance between caster and receiver but with the optional script let's you make them a lot smoother or sharper.
     
    Last edited: Nov 17, 2016
  12. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    To make thing more clear, this shadows filtering works only with Unity renderer. For instance any shader framework or custom shader that uses Unity shadows will work with this shadows. And the good thing, you don't have to touch any of your shaders or frameworks, it will work.
    I'll see if I can use Unity build-in lights properties to control the global smoothness of shadows in a per light basis instead of globally so you wont have to add a script anywhere to your scene.
    [EDIT] Found something interesting.
    In the upcoming version of Unity with Mixed-Light mode, we will be able to set the shadows radius (or penumbra size) but only for baked shadows with this property:

    I can use that property to change shadows smoothness on [SSFS]. As for now, this property isn't available on 5.4 and 5.5. I can use the Strength property to change the smoothness but your shadows opacity will only be driven by ambient and direct/indirect contribution. Using some light property to drive the shadows smoothness avoids adding script to your scene and let you tweak it in a per-light basis (instead of globally).
    What do you guys think?
     
    Last edited: Nov 17, 2016
  13. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    I think unless it's affects performance, I would rather add a script to each light. tieing it to the shadow strength or another property, sounds a little restrictive, the shadow strength is very carefully balanced in my game, so I wouldn't be able to change it much. But that's just me. With alloy's area lights you have to add a script to the light and likewise with hxVolumectic lighting, so it wouldn't be unusual. In fact with hx you have global settings and then the script on the light will override, so basically you can choose, which is nice.

    When you say replace a cginc file inside the editor, do you mean where the exe is, ie if you want to go back to the built-in shadows for whatever reason, you'd need to copy the old one back? - I'd assumed you'd have done it through the graphics section now they've exposed the shadows or am I misunderstanding custom shadow shader they've exposed?

    Either it's sounding really interesting
     
    tatoforever likes this.
  14. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @punk,
    I'll answer those questions when I get back from work.
     
    Last edited: Nov 17, 2016
    punk likes this.
  15. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @punk,
    Back from work! :)
    Unfortunately, for Unity shadows it's a bit different, their depth textures you can't do that, because they are created in the C++ part of the engine, which we don't have access. Unity handles light indexes internally and again I don't have access to it, the C++ renderer feeds shaders with current light type and properties but we don't know exactly which light on the scene is.

    Keep in mind, this system automatically adjusts penumbra size based on caster-receiver distance. For instance, if the light is very close to the caster/receiver, shadows will get sharp, but if the light is far away it will tend to smooth out automatically (kinda more physically plausible). But still, you can optionally change how sharp/smooth shadows are globally at near/far ranges with one global script.

    I can let people change soft-shadows smoothness in a per-light basis by adding scripts to all your lights but will require more MonoBehaviors laying around (on every lights), probably more ShaderKeywords and global properties (plus the fact that I have to set an array of unknown size containing all scene lights on the shader and can get messy), more manual setup to set only one value in the shadows. I'm trying to make the setup as much straight forward as possible (user friendly). But I'll do it anyway if that what's people want. :)
    Also, shadows opacity (or in this case strength) should never be handled the way it is (with a manual override on the light), it should be handled automatically with scene light contribution. For example, I've seen lot of people making their shadows almost transparent on very dark scenes, quite often looking incorrect. So what I want to say is that if you set your scene lighting properly (without touching shadows strength) you should be fine and it will give you more physically plausible results.
    That's why I wanted to use the strength property of the light to override the smoothness in a per-light basis. :D
    If you have an example scene that I can take a look out and see how you setup your lighting, that would be awesome.

    Now for the setup itself. I've already asked Unity folks to let us override point/spot shadows filter thorough Graphics menu (the same way we can do for directional shadows) but they said no. Tbh, I don't know who came out with this poor laziness idea. :D
    Anyway, there's no way we can do that through the Graphics menu for spot/point shadows, only way is to override cginc files in the Editor folder. So yes, you have to backup the file you have to override first (in case something goes wrong). In the case of installing a new version of Unity, you have to do this again. I can create an Editor script that do this file overwrite automatically (In the case of insufficient OS privilege, print a console error asking the user to do it manually). Again if people want it.
    Let me know what you think? :)
    Regards,
     
    Last edited: Nov 18, 2016
  16. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    I think with that explanation it sure does sound like a cleaner way of doing things, I reckon I could live with it ;)
     
    tatoforever likes this.
  17. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @punk,
    Later today, I'll try to put out a demonstration video to showcase the adjustable penumbra size based on distance with moving objects.
     
    AcidArrow, pixelsteam and punk like this.
  18. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Here is folks:

    At the end you can see the global soft-ness in action but still the shadows are sharper if blocker/receiver are close and smoother if blocker/receiver are far.
    Let me know what you think. :)
     
    Last edited: Nov 19, 2016
    punk likes this.
  19. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    So, what you got is a full PCSS filtering for spot/point shadows and a cheaper variant that simulates PCSS and requires less samples. Both techniques automatically changes penumbra size based on distance between receiver/caster and light positions, they are both visually similar but the PCSS is more physically correct.
    The minimum and maximum penumbra size that the shadows can produce can be tweaked on the global script.

    PS: I'll soon record a new one but with spot shadows (which are extra prettier than point light shadows). :)
     
    Last edited: Nov 19, 2016
    AcidArrow and punk like this.
  20. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @tatoforever Thank you very much for your thorough reply! :)
     
    tatoforever likes this.
  21. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    It's the same option that is at lighting -> Object right now. They just made it to appear on the inspector too. I'm not sure if they changed anything, but I don't think there is a way to read that value through scripting and I'm afraid the same will be true for the mixed mode builds.
     
    tatoforever likes this.
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    There's few values that aren't exposed through C# but are feed into shaders by the C++ renderer. Unfortunately after further investigations Unity does not seems to feed it onto shaders yeah. That's why I was suggesting shadow strength. Maybe give people the choice to either use shadow strength value or just globally (as previously suggested).
     
    punk likes this.
  23. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    I like the shadow strength option. I don't really use that option for its intended use, so it would work for me. (and I think a global value is a bit too restricting)
     
    tatoforever likes this.
  24. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I never use it either, because shadows opacity should never be tweaked artificially, it must only come from scene lighting contribution (ambient, direct/indirect, etc).
     
    AcidArrow likes this.
  25. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,539
    Looks great, nice work! Hope it releases soon :)
     
    tatoforever likes this.
  26. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Got an important communication post later today regarding submission to the Asset Store and the state of the shadowing system. :)
     
    Lex4art, Invertex and SteveB like this.
  27. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Alright so last week I've discovered a small caveat which prevents me to properly do PCSS shadowing on spot lights (point lights PCSS are working fine btw). The thing is that Unity C++ renderer forces shadowmap textures to be sampled and compared on the hardware directly and I need to sample the depth instead of getting the shadow sample directly to properly construct PCSS shadowing. I've been looking small workarounds in the mean time (trying to force Unity renderer to declare those textures as depth instead of shadowmaps) and I'll have a definitive answer this week. If by any means, my workaround doesn't work, I will simply fall back to the cheaper PCSS approximation which also computes penumbra size dynamically based on distance from light/caster/receiver but it's less physically plausible than pure PCSS. Still both solutions are better and look nicer than standard soft-shadowing.
    If you want to know how the approximation technique looks like, just head to the first post of this thread with the images on green light. All in all, both techniques looks identical in terms of smoothing and visual fidelity, it's just that penumbra size behavior is more realistic in the PCSS version.
    Keep in mind that you'll be able to chose the shadowing technique (PCSS or the approximation).
    So with that, allow me few more days to see if my workaround works, if not then I'll just finish the documentation and prepare for Asset Store submission.
    PS: Planning to release (or at least submit) before Christmas. :)
     
    Invertex likes this.
  28. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    288
    Please submit this to the asset store so I can give you my money. I'm happy to wait for spotlight shadow support.
     
    tatoforever likes this.
  29. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Hi,
    Submission will happen in the coming days (hopefully before Christmas) and the product should offers you up to 4 shadow types (PCSS and approximation for both Spot and Point shadows) as shown in this thread.
    Upcoming features is PCSS for Directional Unity shadows.
    PS: Keep in mind, this system doesn't require you to do any shader manipulation as it replaces Unity default shadows. I'm reusing Unity built-in depthmaps and applying filters internally before they get used by your shaders/frameworks.
     
    Lex4art likes this.
  30. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    288
    Sounds great. Can't wait to throw it in my game!
     
    tatoforever likes this.
  31. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    OK folks, documentation is almost completed. Asset Store submission tomorrow or Friday 15th. :)
    I'm also finishing a small editor tool that will install the files and set everything up (setup needs to be done only once anyway but the tool will allow you to revert to default Unity shadows too).
    Lastly, what do you think of using Light Hard/Soft Shadow property to switch between the two techniques (PCSS and approximation) in a per light basis? We already know that strength will be used to tweak the penumbra size but using this property will allow me let you chose everything within your light (in a per light basis) and won't require any extra-script (will be faster and won't add any Shader Variant or Keywords).
     
    AcidArrow likes this.
  32. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    288
    If you mean hard shadow = approximation and soft = PCSS (the order that makes sense to me based on expense) then yeah, I like the idea.

    Glad to hear it's almost here - light/shadow are huge in my game and I'm looking foward to adding super sexy soft shadows.
     
    tatoforever likes this.
  33. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @CodeBison,
    Yes, that's what i meant.
    Regards,
     
  34. Pacver

    Pacver

    Joined:
    Oct 11, 2014
    Posts:
    3
    Hi, this asset looks interesting and just what Unity shadows need. I think the screenshots and video you've provided could benefit from taking away the camera effects like bloom and flare. If those screenshots are what you're going to use for the Asset Store page. A side by side comparison between a textured/normal-mapped material and the plain material from your screens would be great too.

    By the way, does the result look good with 2 or more point lights casting multiple overlapping shadows of the same object?

    Looking forward to the asset!
     
    Lex4art and tatoforever like this.
  35. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Pacver,
    I'm working on the Asset Store material which provides a set of zoomed shots with my shadows vs Unity default ones.
    As for the overlapping shadows, it behaves as Unity built-in shadows because it replaces it completely, with the benefit of being visually and physically better.
     
    Last edited: Dec 16, 2016
  36. Manul

    Manul

    Joined:
    Nov 30, 2012
    Posts:
    18
    Whats the state of this project?
     
  37. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @Manul
    Hi, AssetStore submission will happen this week, I'm finishing the Store materials right now. :)
    Will let you know once it's submitted.
     
    Lex4art likes this.
  38. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    288
    Excellent news! I'm excited to combine this with the lighting modes in the new 5.6 beta.
     
    tatoforever likes this.
  39. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @CodeBison,
    I've already tried with the new Mixed light mode and it works like a charm. I've even posted a video below.
    After initial release, if you need access to beta versions, I'll provide you a way through email.
     
  40. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    288
    Sounds great!
     
  41. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    directional light support as well?
     
    tatoforever likes this.
  42. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @nbac,
    Yes, I'm working on directional shadows right now but it will probably won't be available on initial release. You'll have a definitive answer tomorrow (after submission).
     
    Lex4art likes this.
  43. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    A quick question about your second video: What's going on at 2:10?
     
  44. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I accidentally moved the sphere inside the light. ^^
     
    one_one likes this.
  45. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    Wow, these look great.
     
    tatoforever likes this.
  46. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Current Shadow Features (v1.0.1):
    - Point Light: PCSS + Approximation filters
    - Spot Light: Approximation filter

    Upcoming Shadow Features (v1.2):
    - Spot Light PCSS filtering
    - Directional: PCSS + Approximation filters

    New video showcasing Spot-Light soft-shadows close up.

    NOTE: I got the package submitted, going to post the Asset Store images tomorrow. Enjoy the video. :D
     
    Last edited: Dec 31, 2016
  47. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    Wow, this video really shows everything (without all the imagefx)

    Do these shadows work with skinned meshes too?
     
    tatoforever likes this.
  48. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    It's a replacement for built-in shadows, so they work with everything that already has shadows in Unity. :)
    As you can see in the video, it can make extremely very low res shadows very smooth. Which will save tons of fill-rate, hide shadow anti-alias and shadows banding 100%.
     
    Last edited: Dec 30, 2016
    wetcircuit likes this.
  49. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Which of those images you guys like better for the product page?





    PS: I'll add a couple of very close-up images and update the main post later in the day.
     
  50. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    I'd go with the first one, it's easier to see the shadows.
     
    tatoforever likes this.