Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

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

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

?

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

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

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

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

    4.2%
  1. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @NeatWolf
    No worries, every input could always be useful.
    I saw your gif example and yes, cascade seams are visible for two reasons, the first one is already described below (high frequency shadow details on low frequency scenery medium. Second reason, the cascades distance in the example are way too extreme and breaks the stitching algorithm. The stitch algorithm requires twice the distance between each cascade (eg if your first cascade sits at 0.1 unit, your second one should be at 0.2 and your third one should be 0.4).
    Will your final version look like the images you are posting (flat colours, little to no textures)? Otherwise yeah, it seems like you are focusing way too much on small shadow details that will disappear once your game gets textures with high frequency details on it. Premature visual polishing. :D
    PS: I will add the changes for shadowmap mixing in v2.1.
    Cheers,
     
    NeatWolf likes this.
  2. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    845
    Yeah, I knew the numbers were pretty extreme, yet, my question was, would it be technically possible to tweak it so that the stitching doesn't break without touching those parameters? If it's not, no reason to worry :D
    By tweaking, I mean also tinkering with the code in the NGSS source :)

    I wasn't aware of those values, thanks for pointing them out! Feels like a good addition to the docs/FAQs :)

    Yeah, I agree, to a point :)
    I was doing some quick and dirty prototyping pulling out Google Maps data and extruding the edges of a region of a city, to reconstruct a street in particular - possibly getting access to the Maps API pretty soon to fetch proper building geometry (as a ready to use reference for the 3D artists)
    I started with HDRP but I don't feel there's enough support for it to begin a project with it, so I gave up on native volumetrics and and fell back to Aura2+NGSS2, which seems to work pretty well together :) (looking forward HDRP support :p )

    I'm an aficionado of your YouTube channel, so I've been getting all the progress about the asset. All pretty cool demos.
    But I remembered that you always had amazingly smooth transitions, so I felt something was probably wrong with my setup, and I really wasn't expecting to break it - that's why I felt like directly asking to you :D

    Cool! looking forward it :)
     
    tatoforever likes this.
  3. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @NeatWolf
    Regarding the Cascades stitching and seams, if you hover over the cascade properties it will show tips about how it works and how it should be setup. But I'm reworking both Inspectors (Local and Directional) for v2.1 to be more user friendly with simple and advanced tabs, more visible explanation, etc.
    The idea is to have it more self-documented and avoid people referring to the documentation (99% of users don't read documentation, or do it only once anyways). xD
     
    NeatWolf likes this.
  4. stalker_23b

    stalker_23b

    Joined:
    Jul 28, 2011
    Posts:
    87
    Hello,
    i am using NGSS 2 with Aura 2. Setting shadow softness to value lower than 1.0 makes Aura 2 shadows semi-transparent. I tried setting _LightShadowData.r to 1.0 in StoreShadowData shader, but this had no effect.
    Do someone know receipt for making Aura 2 compatible with NGSS 2 shadow softness?
     
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @stalker_23b
    What shadows are you refering to? Did you re-imported aura after making the change? Any changes to cginclude files requires shaders (that uses these include files) to be re-imported.
     
  6. stalker_23b

    stalker_23b

    Joined:
    Jul 28, 2011
    Posts:
    87
    Yes, did reimport and restart, does not help. Btw, i was totally sure that Unity is auto reimporting all shaders which reference changed include file. I am refering to point and spot shadows (checked both)
     
  7. stalker_23b

    stalker_23b

    Joined:
    Jul 28, 2011
    Posts:
    87
    Btw, i am confused, in docs you say
    "...On top of that, if the shader framework internally access to _LightShadowData.r, override that value to 0..."
    but here on forum you said
    "...you just need to override _LightShadowData.r before is used and set it to 1.0..."

    can you please clarify, what is correct in my case - 1 or 0?
     
  8. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    You don't need to restart Unity for the new changes to take place, but sometimes (and I don't know why) Unity does not re-import changes made to cginclude files and thus requires the shader to be re-imported.
    As for the _LightShadowData.r override value, it should be 1.0. I'll fix the documentation for next version.
     
  9. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @stalker_23b
    Btw, a better solution to override _LightShadowData.r with 1, is to replace the line using _LightShadowData.r by a NGSS_GLOBAL_OPACITY define. Overriding the value was for NGSS v1.x but now in NGSS2 we provide our own shadows opacity and is NGSS_GLOBAL_OPACITY. You dont need to declare it, is already declared for you inside NGSS shadow libraries, you only need to replace _LightShadowData.r with.
    So this:
    shadows= lerp(_LightShadowData.r, 1.0f, shadows);
    Becomes this:
    shadows= lerp(NGSS_GLOBAL_OPACITY, 1.0f, shadows);

    In v2.1 i will provide a shader define to avoid having to revert changes back in case you remove NGSS libraries. This tweak only applies to Local Shadows with custom shaders that access independently shadows libraries.
    PS: I'll update the documentation with this important detail.
    [EDIT] Documentation updated. :cool:
     
    Last edited: Mar 17, 2019
    NeatWolf likes this.
  10. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    382
    https://unity.com/ray-tracing

    Will be in 2019.1 :)
     
    tatoforever likes this.
  11. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Yes, I'm so ready! :D
     
  12. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    61
    RTX is just a fraudulence
    Give us something like CryEngine did, for mainstream GPUs
     
    tatoforever likes this.
  13. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    My Idea for NGSS Raytracing version is to use one ray for hardshadows then use NGSS magic trick to filter it! ;)
    More of that soon! :V
     
  14. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Oh btw,
    Using AMD raytracing techniques, you can do real-time raytracing on any ~DX11 capable GPU. Fully accelerated on hardware. Not just some nVIDIA 20XX series. What nVIDIA is doing is kinda abusing being no1 to sell overpriced GPU cards.
    The real secret behind real-time raytracing is not any specific GPU. Is totally accelerated structures (and searching algorithms).
    PS: By raytracing I don't mean full raytraced scene (like path tracing). More like a couple of secondary rays per pixel, like reflections, pixel perfect hard shadows, 1 bounce global illumination, etc.
     
    Last edited: Mar 19, 2019
  15. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    170
    Last edited: Mar 20, 2019
    tatoforever likes this.
  16. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Still,
    Raytracing requires beefy GPUs, that's why no body took it serious until recently. I've played long time enough with OptiX demos and they all run on my 5 years old laptop. But they are demos, engine and games is a different story. :oops:
    So yeah, thanks AMD for not letting nVIDIA abuse the industry. :cool:
     
    alternativevisual and hopeful like this.
  17. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    382
    Well I think the point is that Nvida's hardware architecture accelerates the calculations, which is what a GPU accelerator should do :p SO I don't thank AMD for not doing their job and accelerating raytracing in hardware when they could and should be doing it. :p
     
  18. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Trust me, with dedicated hardware or not. Right now, you will have the same limitations with either AMD or nVIDIA. Around 3-4 rays per pixel.
     
    hopeful likes this.
  19. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    382
    I'll have to take your word for it. My parents raised me to be a good Nvidian, I go to worship GTX every Sunday, so I have to stick by them :p
     
    Lex4art and tatoforever like this.
  20. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    86
    Aren't RT cores supposed to offload the raytracing cost from the rasterization cores?
     
  21. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @tspk91
    The problem with dedicated RT cores is what if I need more RT cores and less rasterization cores?
    Right now the limitations are similar for both AMD and nVIDIA ways of doing real-time raytracing (around 3-4 rpp). To me this nVIDIA RT "dedicated core" is just a way to inflate and rise the price of nVIDIA cards. AMD provides a more general/unified way of using the whole GPU cores for any rendering and triangle testing task.
    From the nvidia devblog: https://devblogs.nvidia.com/rtx-best-practices/
    "The main contributing factors are acceleration structure resources, ray tracing specific screen-sized buffers (extended g-buffer data), and driver-internal allocations (mainly the shader stack)."
     
    Last edited: Mar 21, 2019
  22. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    254
    bonjour @tatoforever Can you explain a bit better what needs to be done for NGSS and Aura 2 to play well together? I'm not sure what I need to tweak or where! I think @raphick, the Aura 2 dev has tried getting in touch with you to coordinate things?
     
  23. alternativevisual

    alternativevisual

    Joined:
    Apr 16, 2015
    Posts:
    61
    Nothing special! It just works o_O
     
  24. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @transat
    bonjour,
    I didn't received any email from @raphick .
    From users experience Aura works out of the box. Some volumetric/shadow dependant assets needs one line of code tweak for their local shadows to play nice with the asset because NGSS still use the shadow strength value for softness tweak.
    Like this:
    shadows= lerp(_LightShadowData.r, 1.0f, shadows);
    It becomes this:
    shadows= lerp(NGSS_GLOBAL_OPACITY, 1.0f, shadows);

    This tweak only applies to local shadows (Spot/Point). Directional shadows don't require this change, I don't use _LightShadowData.r for shadow softness.
    Cheers,
     
    transat likes this.
  25. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    254
    Cool. Yes - the assets seem to work fine together for me actually, as far as I can tell. I was confused by earlier posts and didn't know if I had to change mentions of _LightShadowData.r in your libraries/shaders or in 3rd party assets.
     
  26. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Right,
    If your Local volumes start to leak light, you need to change that value on the volume shader (not on NGSS libraries). If everything looks fine (99% of the time) then you don't have to do anything.
     
    transat likes this.
  27. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    Hi, I just bought the tool, installed the directional library, setup contact shadows on my camera. added the ngss script to a directional light.
    I am seeing some shadow artifacts now, so I was trying to uninstall ngss to verify the source, but there is no .bak file in the CGIncludes folder. did it not correctly make a bak when I installed? do I need to wipe my unity install now?
    thanks

    UPDATE: I uninstalled unity (2018.3.9f1. standard render pipeline, linear, deferred) and reinstalled it, and it appears 1, yes, the original cginc files did not get renamed to .bak files by the install script and 2, the artifacts I was seeing are related to non standard shadowing techniques. At some point I will try a manual install instead and see if that makes a difference.
     
    Last edited: Mar 26, 2019
  28. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @Pheck,
    When you install or uninstall the NGSS Libraries the installer display your CGInclude folder path in the Editor Log. Make sure you are accessing the correct CGInclude path. I've seen people with multiple versions of Unity looking at the wrong directories. :D
    There's an issue with Unity shadow projection in 2019.2 alpha is not NGSS but it affects both Unit shadows and NGSS shadows cause NGSS uses Unity renderer. Are you talking about the same issue I reported couple of messages back?
     
  29. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    I don't believe its the same issue, here is a screen shot. this is in 2018.3.9
    it happens at sharp angles where the sun is close to parallel with the wall, but not exactly parallel. I cant just move the sun or wall a little in this scenario either.
    I am seeing a few other artifacts, but until I can verify my install is working correctly with the tool, this is the only one I can reliably report on.
    .. oh ya... if I rotate the camera and look at the wall at different angles the problem shows up more or less, so its camera angle relative.
    upload_2019-3-25_19-15-19.png
     
    Last edited: Mar 26, 2019
  30. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    No,
    That's the ContactShadows bias, try to rise it a bit more till it disappears.
     
    hopeful likes this.
  31. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    hmm, do you mean "Shadow Frustum Bias"? Contact shadows dont have a Contact Shadow Bias variable in my interface. The shadow bias in the light doesnt impact this issue.
    I had to crank the frustum bias so far to remove the issue on the wall, it just moved the issue onto other objects.
    below is a screen showing how the issue showed up elsewhere. (the dark angular patch on the building in the bottom right)
    upload_2019-3-26_9-45-8.png
    upload_2019-3-26_9-47-2.png
     
  32. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @Pheck
    It's possible for your to send me a test scene with that building? I would like to do some tests on it.
    I did some changes in the last updates to ContactShadows bias, maybe I need to re-visit or roll it back to other previous (working better) version for the bias. Using some of these buildings will help me out quickly spot any real world-case issue. :)
    Cheers,
     
  33. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    I can send you the building, but not the scene. the project is many 10s of gigs and is currently under NDA.
    The problem shows up on any object though. ill see if i can repro in a empty scene with a box with a few minutes of effort.
     
  34. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    UPDATE:
    to repro, create a new scene. add a cube. add contact shadows to the camera. hook up the existing directional light from the scene. scale the cube to 10,10,10. rotate around the cube until problem repros.
    (left side artifacts as i rotate.)
    upload_2019-3-26_10-11-48.png
     
  35. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    depending on the angle of the camera, it should repro on at least two sides.
    upload_2019-3-26_10-13-17.png

    If you find something, I would be happy to test it out for you.
     
    Last edited: Mar 26, 2019
  36. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @Pheck
    OK, I see what you mean. Yes is probably the changes i did in the last couple of 2.0.x updates to the ContactShadows bias. It made is more precise but at risk of having more frustum artifacts like that. I will take a look at your described example and get back to you later (probably submit a quick fix this week too).
    Cheers,
     
    hopeful likes this.
  37. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    possibly your new precision changes could be turned on via a bool? supporting both old and new.
     
  38. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @Pheck
    If the new one creates only more artifacts there's no need to keep it. If the new ones provides some advantages then why not keep both yes.
     
  39. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    237
    Hello @tatoforever

    Purchased and installed NGSS 2 into my VR project today and may be getting some performance issues. I'm using NGSS on a single directional light outside with a fairly small terrain. Perhaps worth noting, that my main scene is loading other scenes additively.

    Before installing my lighting setup: stable fit, distance 100, cascades 4, resolution medium.

    After installing NGSS 2: stable fit, distance 100, cascades none, resolution low, with all NGSS settings on the VR recommended or lower.

    In the editor (Unity 2018.3.10f) - I keep getting these weird perforance spikes on a fairly regular basis and CPU load is higher than it was before NGSS. My performance before < 10 ms for VR is now > 15ms in the editor.

    In the build - no performance spike and performance is 10-15 ms in the more intensive areas, which is an increase for sure.

    From reading your PDF and based on my settings this seems wrong? I should have actually increased performance not lost it?

    Any pointers appreciated, thanks!

    // WildStyle
     
  40. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @WildStyle69
    Hi,
    Unity Editor is acting very weird last couple of versions, I'm also having lot of Editor GC spikes but that isn't NGSS. Is something else triggering GC spikes. If it happens for you to have the spike when NGSS components are in the scene then they are triggering some weird bug in the Editor but that still Unity because NGSS component don't do anything special except update couple of global shader properties. Do you have other Inspector plugins or libraries? I've seen weird stuff with custom inspectors from the asset store too. The reason why I'm telling you this is because you don't have the spikes at build, only in Editor.

    For your VR needs, if you want to increase the performance a little bit more: Uninstall all NGSS libraries (using NGSS tool) and just leave the NGSS_Directional component on your directional light with the recommended VR default settings. This will disable Denoiser and is not needed for VR projects so you should gain a lot fps.

    Let me know if it helps.
     
    WildStyle69 likes this.
  41. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    237
    Thanks @tatoforever

    So I removed the NGSS libraries, did a bit more tweaking and then created a new build. The result is good, as I have indeed saved some FPS compared to the default Unity shadows and they still look decent, so that's a big win. Thanks for a such great asset!

    // WildStyle
     
    tatoforever likes this.
  42. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @WildStyle69
    A nice review of your findings and journey with NGSS would be appreciated! :)
    Cheers,
     
    WildStyle69 likes this.
  43. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    @WildStyle69 would you mind sharing your NGSS Directional settings? I've been fussing and fussing with them, but can't get any improvement over lighting/shadows without NGSS. (i undestand NGSS is mostly for better quality with equivalent performance, but I really need some help reducing GPU load from shadows -- lots of tree branches casting shadows in my game.)
     
  44. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    237
    Actually @gecko -- I've been doing some more testing in different builds today and have made the decision to roll back to Unity default shadows, reason is performance. I found the NGSS shadows did not perform well on the larger open parts of my terrain and I was losing FPS that I didn't lose with the default Unity shadows with 4 cascades.

    So I rolled back a commit and have been testing with Unity shadows and found that I can tweak those about a bit, increasing resolution and removing cascades.. finding myself in a position where I can gain around 2-3 ms of performance, depending on where I am in the level.

    I think I'll still use NGSS shadow on some other areas, but on the larger open world parts of my VR experience the perceived quality is not worth the sacrifice in FPS.

    // WildStyle
     
    gecko likes this.
  45. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    @WildStyle69 thanks very much for that info. I'm in the same situation, and since I have a very noisy environment (grass and bushes etc), I care less about shadow quality (which NGSS excels at) than raw speed. (But still hoping that future NGSS updates will help in that regard.)
     
    WildStyle69 likes this.
  46. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Hi,
    I fixed the self shadowing problem with ContactShadows and will be submitted for review tonight.
    On top of that I added a massive optimization for ContactShadows in Deferred pipeline that skip all shadowed fragments and backface shadowing is also improved.
    Poke me through support email if you want to get access to it right now.
    Cheers,
     
    Last edited: Mar 30, 2019
    Bzuco and hopeful like this.
  47. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    Folks,
    NGSS v1.0.8 will be submit tomorrow, new and changes:
    upload_2019-3-30_21-54-38.png
    - Improved self-shadowing bias for Contact Shadows (fixed silly artifacts at sharp angles)
    - Deferred Backface Optimization. Skip fragments that are not facing the light (Improved performance a lot)
    - Deferred Backface Translucency. Let you set how the backface is lit (0 = black, 1 = no backface shadows).
    Deferred Backface options requires deferred rendering and Gbuffer normals. Use the Editor View Deferred Normal mode to debug your shader. Transparent or Forward shaders won't display ContactShadows correctly if this option is enabled.

    - Added compiler define for NGSS_Local shadows NGSS_GLOBAL_OPACITY (useful to avoid compile errors if you update/install Unity and your custom shaders have references to NGSS_GLOBAL_OPACITY)

    - Updated documentation
     
  48. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @Wildstyle
    Did you tried disabling Cascaded Shadows with NGSS Directional libraries installed? It will automatically enable the optimized directional NGSS path and should improve the performance quite a lot compared to NGSS Cascaded Shadows.
     
    Last edited: Mar 31, 2019
    hopeful likes this.
  49. Pheck

    Pheck

    Joined:
    Jul 9, 2009
    Posts:
    179
    I have seen some of the posts say they saw a perf gain by switching to use ngss. i know perf is circumstantial, but did they see one on cpu or gpu? i need to save some cpu shadowing related costs could ngss would help with that?
     
  50. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,869
    @Pheck
    Depends on your shadows setup and target platform/hardware. Don't expect an extreme performance gain, what you can expect is surpass Unity default shadows quality with similar performance.
    EDIT: GPU Performance yes, CPU nothing changes, still the same Unity depth maps being rendered with builtin renderer. Version 2.1 has a shadow caching feature that will improve CPU performance monumentally on large populated open areas.
     
    Last edited: Apr 2, 2019
    gecko likes this.