Search Unity

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

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

?

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

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

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

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

    4.2%
  1. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Abuthar,
    Is that behavior with Point/Spot lights or Directional lights?
    Also can you post images/gif or videos? Help me understand better the problem.
    Regards,
    [EDIT] Sorry misread your initial post. Yes you need to edit Pre-Integrated Skin shader (look for their core cginc files) and remove their shadow strength value usage (set the value that uses _LightShadowData.r it to 1). Or shot me an email with your pre-integrated skin shaders and I do it for you. Don't worry I own a license to it (lot of people asking for it, had to buy one). :)
     
    Last edited: Oct 14, 2017
  2. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    tatoforever likes this.
  3. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    @tatoforever Hey, any word on that modification for transparent objects receiving shadows? Cheers
     
  4. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    I have done that, but still doesn't work. Seems like everything is setup correctly. We only use direction light btw. Have you tested it on Unity 2017.2 with directional light ang NGS? Great if you can give me some feedback regarding weather it works or not. Thanks!
     
  5. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    70
    I did. Here it's working in 2017.2f3, where I'm adjusting the global softness of the directional light at runtime: https://c.lewd.se/Osia4A_2017-10-14_16-55-12.mp4
     
  6. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
  7. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @olavrv,
    It doesn't matter as shadow functions are separate from lighting function (on Unity internal cginc rendering files) and NGSS is not any different. We override the internal shadowing computations only but even file names and functions remains the same. Unity don't even know we are doing custom shadow filtering with their own depth maps. ;)
    We've updated our current console project to latest public release (2017.2) and it works 100% fine. So yeah, either you are doing something wrong with setup or you've replaced maybe some other files?
    But do let me know if you keep having issues.
    If you got TeamViewer I can do remote support and do the install for you (maybe you skipped some of the steps?) Who knows. ^^

    @Invertex,
    Hey my buddy, I've been quite busy lately with a huge update we are doing for our mobile game Forgotten Memories (graphic renderer update) and didn't had any free time to do it. I'll give it a go tomorrow. In case I forgot again, please send me an email through support.
    PS: I'm going to offer free to anyone (won't be part of NGSS 1.x though).
     
    Last edited: Oct 15, 2017
    Invertex likes this.
  8. Yuki-Taiyo

    Yuki-Taiyo

    Joined:
    Jun 7, 2016
    Posts:
    72
    Hello there. I got NGSS some weeks ago, I can say I'm totally satisfied with it and left a 5 Stars review on the Asset Store.

    Yet I'm actually facing a technical issue with the Directional Light : When the light is facing the world straight down at 90° (like 12 AM), they create black artifacts all over the place and make the shadows and noise bleed a lot. I don't have fancy settings (only shadow distance at 1500) and I use UBER for my materials.

    Anyone else experienced this ?




    You actually can't see the artifacts acting and the noise bleeding but I think it's quite visible. They also make too much stripes, especially at narrow edges like 80° towards the ground.

     
    Last edited: Oct 15, 2017
  9. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Yuki-Taiyo
    Hi, are you using ContactShadows? If so, what are your settings? Also, I need to know your Directional Shadow settings. Can you provide a small test project with that scene (send it to support)?
    Regards,
     
    Last edited: Oct 15, 2017
  10. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    Seems that feature in latest Unity (2017.1.1 and higher) about "you can set shadow resolution up to 8192px on any light via scripting" actually working (but still, I don't feel like I have that full 8K shadow map resolutin :/ ). Here is my script for that (attach it to a light and that is it, in play mode it will set shadow resolution to that value):
    SetShadowResolutionOnLight.png
    Results with default "Very High" shadows:
    UnityShadowsOnVeryHigh.jpg
    Results with script set to 8192px shadows:
    UnityShadows8192px.jpg

    Here is the script code (or you can use one from attached unitypackage file):
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Rendering;
    5.  
    6. public class SetShadowResolution : MonoBehaviour {
    7.  
    8.     public int givenResolution = 8192;
    9.  
    10.     void setShadowMapResoluton(){
    11.         this.GetComponent<Light> ().shadowCustomResolution = givenResolution;
    12.         print (this.GetComponent<Light> ().shadowCustomResolution);
    13.     }
    14.     void Start ()
    15.     {
    16.         setShadowMapResoluton ();
    17.     }
    18. }
    19.  
    Combine this with NGSS and you are golden ). But remember to check performance 8192px shadows are expensive...
     

    Attached Files:

  11. Yuki-Taiyo

    Yuki-Taiyo

    Joined:
    Jun 7, 2016
    Posts:
    72
    No, I'm not using Contact Shadows ; I haven't saw what this is exactly and how to use it.

    Here's my Directional Light settings



    And here's what happens when I use BIAS_FADE with the light still hitting the ground at 90° :


     
    Last edited: Oct 15, 2017
  12. Yuki-Taiyo

    Yuki-Taiyo

    Joined:
    Jun 7, 2016
    Posts:
    72
    Nevermind : It was because of the Bias settings set to 0. I set them to 0.15 and I everything works now. :)

    Just how can I increase the Directional Shadow quality (lower aliasing) on a large world with distance shadows set to +2000 ?
     
    Last edited: Oct 15, 2017
    hopeful likes this.
  13. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    My post above (increase shadowmap resolution) + playing with each cascade distance to move harsh shadows away + playing with softness of NGSS.
     
  14. Yuki-Taiyo

    Yuki-Taiyo

    Joined:
    Jun 7, 2016
    Posts:
    72
    I tired your script but it doesn't change anything.
     
  15. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    It works only in Play mode (e.g. script needs to be executed to affect shadows) and only in latest Unity's versions (just to be sure).
     
  16. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Yuki-Taiyo
    Yeah,
    Bias set to 0 means no offset between objects rendered in depth and objects rendered in display view (two pixels rendered in the same position) == z fighting (or shadow acne)! The option is there to apply that offset. Glad you sorted it out. :)
     
  17. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    At 8K per shadowmap you will drain your GPU bandwidth really fast, even with little to no filtering. This is actually good for rendering CutScenes in a controlled environment with Cinemachine and the likes but not good for actual gameplay with plenty shadowed lights everywhere. But heck, if your game can afford it, go for it. :D
     
    punk likes this.
  18. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    Tried On 2017.1.1f and the max is 4096 for a directional Light, 1024 for a point light and 2048 for a SpotLight, anything above those values does nothing for me. You can set a custom resolution, but it's still capped at the 'very high resolution' option that unity provides us. Now, if it was possible to get a 2k point light or an 8k directional, that would be super cool :)
     
    Lex4art and buttmatrix like this.
  19. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Abuthar,
    You don't wanna do 2K res on point light shadows. Remember that every point light shadows in Unity is 6 spot light shadows. ^^
    NGSS 2.0 will provide hemispherical shadows which are the equivalent of 3 spot light shadows for a full 180 shadow support. Quite often, point lights are close to wall and there's lot of fill rate and memory wasted rendering walls behind it where shadows aren't visible. And due to the fact that it works with a shadowmap atlas, it saves a lot. Plus the fact that it renders only visible objects moving (static objects renders only once), it is fast!
    On the filtering side I'm filtering all light screen space only once (instead of one filter per light at light space).
    It's far from done but heck is fast, zillions times faster and prettier than current shadowing system in Unity.
    This performance gain will allow me to implement even newer filtering techniques and experiment new ground up stuff.
     
  20. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    might be nice for capturing fancy screenshots though
     
    tatoforever likes this.
  21. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    I agree 100% for traditional games, but my project is directed towards artists, so accuracy/realism are key! BTW i fixed the shadow problem with Pre-Integrated Skin Shader. However I'm still having that transparent shadow on point and spot lights, regardless of the shader. Not a huge deal, but kind of annoying


     
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Abuthar
    Please, email your files to support, I'll do the change for you later today.
    Regards,
     
  23. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    171
    Unity 2017.2.




    The cube and plane that are shadowed should not have that light bleed. It worked fine on unity 5.6x.
     
  24. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Crystaline,
    Unity 2017.2:

    Make sure you've redo the NGSS setup (install cginc file and delete your project shader cache folder) after installing Unity. It must be done every time you install a new Unity version as the cginc is replaced upon Unity install. Not needed for Directional/Contact Shadows, only for Point/Local shadows.
     
  25. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    171
    Well.. I did that, countless times. And still the light bleeds through objects. Takin in the fact that my game is also very dark, lights going through walls is really visible. Works perfectly fine with unity built in shadows.
     
    Last edited: Oct 18, 2017
  26. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Crystalline,
    Do you have the same behavior with default Unity shadows (light leaking)? What does tweaking Shadows Strength do to your shadows? Lastly, are you using custom shaders or those are default Unity Standard shaders?
     
  27. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    171
    It works just fine with built in shadows. No matter what tweaking i do to the light , it still bleeds. Bias, near plane , hardness, no matter what. Adjusting shadow strength will tweak the smoothness of the shadows.

    Using unity default standard shader.
    Its like the shadows dont have full intensity or something like that.

    Here are the built in shadows.
    https://imgur.com/uSdzciu
     
  28. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Crystaline,
    NGSS uses the shadows strength value to set the softness and if your shader does shadows transparency then that's what's causing the problem (you'll need to tweak a value on it if thats the case). Otherwise then it must be your ambient lighting in your scene as light should not leak if everything is working fine.
    You said it was working fine in Unity 5 right?
    Can you please submit a Test project to support showing that problem? I will take a look and get back to you later.
    Regards,
     
  29. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @Crystalline
    I've identified the problem with point light shadows and it got fixed. Also I've improved the quality of point light shadows, for free!
    Before (current asset store version):


    After (upcoming asset store version):


    Opacity issue fixed:


    Anyone willing to get this version rightnow, please send a message to support.
    PS: Happy Halloween everyone!:)
    Regards,
     
  30. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    155
    Hello tatofever! Your updates seem really promising!

    I just encountered an issue while trying to build a scene. I get this error message :

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

    Compiling Fragment program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP

    Do you know what is causing it? Can it be fixed? I'm on 2017.2.0f3

    Have a good day and keep up the good work! :)
     
  31. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Hi arnoob,
    Please remove DX9 from your target platform if you are not targetting DX9. I'm fixing it right now.
     
    arnoob likes this.
  32. Abuthar

    Abuthar

    Joined:
    Jul 12, 2014
    Posts:
    92
    Looks great, i'll be supporting this update!
     
    tatoforever likes this.
  33. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @arnoob,
    I think i found the error. Either Unity or Microsoft are wrongly compiling the shader in some target platforms, here's the compiled assembly faulty portion (line 21 for comment):
    Code (CSharp):
    1.  
    2. Shader Disassembly:
    3. //
    4. // Generated by Microsoft (R) D3D Shader Disassembler
    5. //
    6. //
    7. // Input signature:
    8. //
    9. // Name                 Index   Mask Register SysValue  Format   Used
    10. // -------------------- ----- ------ -------- -------- ------- ------
    11. // HERE, passing SV_POSITION is invalid as an input semantic, it must be POSITION instead
    12. // SV_POSITION              0   xyzw        0      POS   float   xy
    13. // TEXCOORD                 0   xy          1     NONE   float   xy
    14. //
    15. //
    16. // Output signature:
    17. //
    18. // Name                 Index   Mask Register SysValue  Format   Used
    19. // -------------------- ----- ------ -------- -------- ------- ------
    20. // SV_Target                0   xyzw        0   TARGET   float   xyzw
    I'm gonna keep investigating but it looks like a shader compiler problem. Some one already sent me a similar issue they had on support.
     
    arnoob likes this.
  34. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @arnoob,
    I found a solution, add #pragma target 3.5 in all the shaders causing this error. This will completly remove DX9 from your target platforms where the compiling error is occurring.
    I'm still investigating and will get back to you when I found something.
    You only need to add #pragma target 3.5 to NGSS_ContactShadows.shader and NGSS_Directional.shader. This fix will be included in this week update (submitting tonight).
    PS: Pragma Target 3.5 do works with OGLES 3.0 and Metal (in case you where wondering about mobile). :)
     
    Last edited: Oct 25, 2017
    punk, arnoob and hopeful like this.
  35. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    NGSS 1.5.8 submitted to the Asset Store.
    Contains the new improved point light shadows filtering, fix for point shadows leaking light (when ambient is low) and getting rid of all compiler warnings and errors when building.
    Version 1.6 will provide new cascade shadows blending for StableFit projection modes and some other tiny requested features from users.
     
    arnoob, No0B25, Lex4art and 2 others like this.
  36. arnoob

    arnoob

    Joined:
    May 16, 2014
    Posts:
    155
    Thank
    Thank you very much for your quick support! I am not really at ease with changing the code by myself, and as I don't need to make a build until Monday I will wait for the update on the asset store to keep everything clean. Again, than you a lot.

    By the way, are you still looking for volunteers to test a new massive point light system? I am currently creating a huge architecture city area (kind of dishonored style) and I am wondering how to light it at night (lots of lights from spot lamps and geometry). It might be a good scene to test the limits! :)
     
    tatoforever likes this.
  37. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    New version 1.5.8 is out on the store. Recommended to upgrade as soon as possible as it fixes build warnings/errors and improves point light shadows quality a lot. :)
     
    arnoob and Akshara like this.
  38. bradbecker

    bradbecker

    Joined:
    Dec 26, 2014
    Posts:
    130
    Just installed new version but getting errors: shader error in Standard (and Standard Specular setup): failed to open source file: 'UnityStandardShadow.cginc'. I replaced the UnityShadowLibrary.cginc like the instructions say but I didn't touch any thing else--nor do I see that file in the CGInc directory. Any ideas?
     

    Attached Files:

  39. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @bradbecker
    - Download the new NGSS version (from the Asset Store) and close Unity
    - Replace the UnityShadowLibrary.cginc library in the Unity folder
    - Delete your Shader Cached folder in your project
    - Enjoy
    :)
    NOTE: Is not UnityStandardShadow.cginc, it's UnityShadowLibrary.cginc that you need to replace. You probably deleted UnityStandardShadows, that's why it can't find it. If that the case, re-download the Unity built-in shaders from the Unity web site and replace UnityStandardShadow.cginc file on CGInclude folder (Unity install directory). Or re-install Unity again (and re-install NGSS again).
     
    Last edited: Oct 27, 2017
  40. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    This seems like a great feature. It's always baffled me that Unity renders shadowmaps every frame when nothing's changed in my lighting. I'm super excited for NGSS 2.0 -- do you have any screenshots or anything?

    I, too, would love to be able to have gigantic shadow-casting point lights. My game has a lot of big caves I'd like be able to light up from the middle. Right now point lights crap out at about size 30, it'd be great if that could be 500, or just never? Maybe point lights with cascades or something? I understand that they're about as good as they can get with the current system, but that would be a killer feature for me in 2.0.
     
    tatoforever likes this.
  41. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @brisingre,
    With giant atlas you will be able to use larger portions to allow bigger point lights but remember that bandwidth is not infinite (neither memory) and you will be limited by shadowmap atlas size. In other words, you can have lot of tiny point light casting shadows or few giant point light casting shadows.
    Quality is slightly better than current highest quality featured in v1.5.8 but performance is zillions faster. And this is only the barebones to newer filtering and algorithms furthermore! :D
    Once I'Il be done finishing NGSS 2.0 I'ma integrate in our console project and provide a video showcasing gameplay with lighting and shadowing in a modern console game.
    Near future, no ETA yet for v2.0! NGSS 1.X still got a couple of new small features and improvements left! ;)
     
    Last edited: Oct 30, 2017
    alternativevisual and brisingre like this.
  42. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    So performance mostly has to do with the total atlas size, and we'll be able to allocate that however we need without impacting it too much? That sounds like a great system.
     
    tatoforever likes this.
  43. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @brisingre,
    Yeah, global impact will mostly be defined by atlas size (bigger shadowmap altas = more memory + more bandwidth) as shadows filtering for all lights are done only once entirely at screen space. :D
     
    Abuthar and brisingre like this.
  44. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Other performance factors are of course the amount of dynamic objects rendering into the atlas depthmap.
     
    brisingre likes this.
  45. tri-stratos

    tri-stratos

    Joined:
    Jan 29, 2013
    Posts:
    152
    [3USER=6538]@tatoforever[/USER],

    On an ordinary sculpted unity terrain with simple unity grass and an ordinary directional light, with your asset set to light and camera accordingly, when the directional light is rotated/moved OR the camera is rotated/moved in certain angles, the nextgenshadow effect simply vanishes. It completely vanishes not getting soften out. As if it has no effect to the scene.
    As such, while light or camera changes position or rotation, there is a total shift in the viewport that seems as if the effect from on turned off instantly, producing a very ugly result.
    Is this a known issue?
    If yes, is there a workaround or a property that needs to be set otherwise for it to work properly?
    If not, would it help a video for you to check?
     
    Last edited: Nov 3, 2017
  46. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @tri-stratos
    Can you please provide images or a small video of your issue?
    Also, provide more info (images) about your scene and project shadows setup (Quality, Light settings, etc).
    Regards,
     
    Last edited: Nov 3, 2017
  47. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    254
    Hello
    I have this problem
     

    Attached Files:

  48. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    @claudius_I
    I need more info about your NGSS and lighting setup but it looks to be ContactShadows wrongly setup.
     
  49. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    254
    Hi
    it's weird, because before i didn't have this problem.

    the chains before didn't have shadows without Next-Gen Soft-Shadows.
     

    Attached Files:

  50. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    609
    Did you try adjusting the ray thickness?