Search Unity

[Released] SE Screen-Space Shadows

Discussion in 'Assets and Asset Store' started by sonicether, Dec 7, 2016.

  1. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    70
    This is where Scriptable Render Loops would enter the stage, which would make this a pain to install when the lighting was already tweaked and not Unity-update-proof.
     
    RB_lashman likes this.
  2. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I have only one question before buying this, how well does it scale with all the post-procs effects? Do I need to apply it before or after them? Or is it influenced by them in any 'bad' way?

    If that's settled I'm in buying this :)
     
    RB_lashman likes this.
  3. RB_lashman

    RB_lashman

    Joined:
    Aug 15, 2013
    Posts:
    92
    well it "augments" Unity's directional light shadows, so you probably want to have it near the top of the stack, i would imagine
     
    TheMasonX likes this.
  4. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    70
    It doesn't matter. I'm putting it before AO just to be sure, but I can't make out any visual difference when putting it at the end of the stack. It's applying a command buffer to the camera. Performance-wise it's about 0.65ms for a Full-HD frame on a GTX680 while in a dense forest with terrain and 3D grass.
     
    TheMasonX and RB_lashman like this.
  5. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    So I'd have to apply them before the Unity's post-proc behaviour. Thanks for the tip, looking forward on grabbing this one.
     
    RB_lashman likes this.
  6. env_warby

    env_warby

    Joined:
    Nov 22, 2013
    Posts:
    23
    thanks for the info !
     
    RB_lashman likes this.
  7. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Hi sonic !!

    I am interested in your asset but I have some doubts

    Can it be used with scenarios that have day / night cycles with real-time lighting? Maybe it's a stupid question but it's not clear to me.

    Do you plan to include rendering path forward?

    Would it work with any type of shader in the material? Ie ... I use infiniGrass and do not know if your asset would be compatible.

    regards
     
    RB_lashman likes this.
  8. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Hi @sonicether ,

    I was browsing through all of your assets I wasn't aware of and was particularly impressed by this, and this image in particular:



    The shadows on the grass really seem to be fading on the tip, like they were using the alpha channel of the texture to make the calculations.

    1) I'm not sure if it is a coincidence. Does this mean that this kind of scattering could be applied to particle systems that write on the Z buffer?

    2) Is there any chance you could combine this with an integrated ambient occlusion shader/color bleed for performance sake?

    3) I bought it on the fly, but later realized it was in the DX11 Subcategory of Unity. Is this really DX11 only compatible or there is a pale chance to obtain the same effect in DX9 as well? Will the system fallback automatically to the default shadows on a non compatible device? Will we able to determine if the SE is going to work on a certain device and manually switch it off and use the default Unity shadows?

    4) Any chance you could introduce shadow distance scattering? This may not be the technical term. I mean: having crisp shadows at the base of the object (eg: a tall cilinder) and a very blurred on at the end? What about simply fading out the shadow, if the above solution is too heavy?

    Thank you :)
     
    nxrighthere and RB_lashman like this.
  9. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    @sonicether Very impressive work! Can you, by any chance, outline how hard would it be to make these shadows work with recently released pipe and area lights from Unity? They are done using command buffers in deferred rendering, if that's relevant.
     
    RB_lashman likes this.
  10. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    Has anyone done any testing on super-large scale applications?

    I'm thinking - could this be used to do shadows for a city as viewed from high up in the sky, where traditional shadow mapping just doesn't have the finesse to handle such things.
     
    RB_lashman likes this.
  11. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Hello!

    I have a very specific question ... in paragon, unreal use shadow map to approximate hair thickness, when comparing the fragment to the shadowmap position, if it's below a shadowmap sample they use the distance instead of the comparison to blend a color accordingly (ie the thickness relative to the first light blocker).

    The question is, how easy it's possible to tweak the shader to have "contact thickness"?
     
    RB_lashman likes this.
  12. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    As others have said, it doesn't matter what order you place the script on the camera or what other effects you have going as long as you're using DX11 and deferred rendering.

    It works just fine with day/night cycles.

    Forward rendering path support is not possible, because there's no way to blend the screen-space shadows in with the traditional shadows properly in forward rendering. Consequently, only deferred-compatible shaders will receive screen-space shadows.

    1. I'm not sure about z-writing particles. As long as they use a deferred-compatible material, I don't see why they wouldn't work.

    2. Probably not, since the tracing that's going on is going to be slightly different than tracing for ambient occlusion.

    3. I can probably get a dx9 version working and put out an update for that. That'll be handled via fallback shaders. I'm already using a fallback shader for Mac support, so I could just add another fallback for dx9 only support.

    4. This would require tracing many rays which would degrade performance quite a bit. The shadow does have an adjustable "fade out" applied to it, as you can see in the screenshot you referenced.

    Screen-space traced area shadows would require tracing many rays/way more samples and would be impractical for that reason.

    This effect has an "accumulation" property that sort of acts the way that you're describing. Lower accumulation values allow some light to bleed through the thickness of a surface before terminating.
     
  13. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    Unity's forward directional shadows are also done in a screen-space deferred manner. It just needs to be done as a command buffer attached to the light instead of a camera image effect. Assuming you only need the camera depth texture to do the effect, you should be able to just render the SSS directly into the screenspace shadow mask.

    https://docs.unity3d.com/ScriptReference/Rendering.LightEvent.AfterScreenspaceMask.html

    Forward rendered objects that have a shadowcaster pass inject themselves into the depth and albedo. Again assuming your effect only needs the depth this should work, even with particles, though they dont write to the normals which causes some pain for SSAO.
     
    buttmatrix, ftejada and RB_lashman like this.
  14. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    Strange, because I tried this, and it didn't work. Is there some sort of configuration that enables or disables this screen-space pass for directional shadows in forward rendering? Perhaps I had it disabled...
     
    RB_lashman likes this.
  15. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    It's disabled for mobile, and in 5.3 and earlier it can manually be disabled in the settings file (though not exposed in the editor), it would also sometimes not be enabled if cascaded shadows were turned off. Otherwise if you have cascades turned on Unity has to render them in the screen space style as the shaders don't support cascades otherwise.
     
    NeatWolf, ftejada and RB_lashman like this.
  16. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    Okay, I'll look into this. Thanks!
     
  17. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    thanks for the reply.

    If the shader works with deferred mode means that it is compatible with your asset, right? Although I have seen the information that has contributed bgolus, I hope you can also upgrade to support forward rendering

    regards
     
    RB_lashman likes this.
  18. Blackfire-Studio

    Blackfire-Studio

    Joined:
    Dec 17, 2013
    Posts:
    185
    @sonicether, @bgolus I thought about the same thing concerning screen space forward shadows. This might be possible according to the way Unity handles shadows when you're not targeting mobile platforms.
     
    RB_lashman likes this.
  19. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Support for DX9 and possibly forward rendering are good news indeed!

    I think I may be missing something tho. If the shadows have already got an adjustable fade out (and this feature alone would have been enough me to buy the package), why is the grass receiving the fading shadow, but the fence isn't?

    Since area shadows would require an excessive scattering to look good, I believe that distance fading would be a nice alternative. I kind of hate having al those sharp (well, sometimes) almost raytraced shadows everywhere! (personal rant :p )
     
    RB_lashman likes this.
  20. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    423
    Wow!
    You are doing such a great job!
    Firstly I was impressed by SEGI, which is amazing!
    Now you made this!

    Thanks you! You pushed the level of graphics on Unity to the new level, and your tools is very important for our project.

    Also I am like your way to showcase a tool, "before / after" images and even interactive images on your website.
    It is important for such tools.
     
    Last edited: Jan 9, 2017
    RB_lashman likes this.
  21. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Couldn't they be "naively" treated as point or directional sources for the purposes of those shadows, since influence of area on penumbra isn't really great anyway in short range contact shadows this effect is covering? :)
     
    RB_lashman likes this.
  22. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    The grass doesn't have shadowmap shadows, so the screen-space shadow fades into nothing. The fence and other geometry have shadowmap shadows, so the screen-space shadows fade into those shadowmap shadows. The fade itself helps blend the transition from screen-space shadows to shadowmap shadows.

    Sure, but for the best effect it needs something to fall back on (shadowmap shadows). Plus, I'd pretty much have to rewrite the shader for area lights for this.
     
    RB_lashman likes this.
  23. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    Hey guys, I'd just like to encourage you to share any screenshots you'd be willing to share in this thread! With your permission, and with credit given, I'd like to feature some screenshots from users on the webpage and Asset Store page for this asset!
     
    eskovas, Kolyasisan and RB_lashman like this.
  24. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    397
    Well, I kinda have one, but I don't know if it's good enough. sample.jpg
     
    RB_lashman likes this.
  25. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
    Hey, thanks for the asset.
    Is there some way to exclude objects from casting shadows? I would like to have my grass unaffected. I can receive great results on normal geometry, just on grass it doesn't really look that great. Thanks!
     
    RB_lashman likes this.
  26. semaphore

    semaphore

    Joined:
    Mar 21, 2011
    Posts:
    49
    ikazrima, Lex4art, Pecek and 8 others like this.
  27. IronDuke

    IronDuke

    Joined:
    May 13, 2014
    Posts:
    132
    Dang, the difference it makes to shadows on the character is impressive!:eek:
    Also, that game looks kinda cool!:cool:

    --IronDuke
     
    RB_lashman likes this.
  28. ArtisticSliz

    ArtisticSliz

    Joined:
    Jan 4, 2014
    Posts:
    40


    This is super impressive, and I understand that you're comparing it to other screen-space features because of the way it operates. But could you run a straight comparison of it versus Unity's basic lighting system, and then coupled WITH that system as it should run? I'd love to see the frame rate or time impact of the combination.
     
    TheMasonX and RB_lashman like this.
  29. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    It's unlikely that you'd get a useful comparison out of that. Screenspace effects like FXAA and SSAO and these SS Shadows, are generally decoupled from what is actually on the screen, the only thing that affects them is screen resolution and what quality you set the effect to (High, Med, Low).

    Both Unity's main renderer and the shadow renderer (has to render everything again to generate shadow maps) DO scale with that's in the scene. So, if you had a flat plane, with just a cube and a directional light, screen space shadows might take longer to render than everything else (Unity shadows and all else) combined, but if you have a complex scene, where the Unity shadow renderer has to re-draw a thousand objects to cast shadows; the screenspace shadow performance shouldn't change much if at all.

    If you want to get an idea of how it runs, add the FXAA post-effect twice on your camera, that's roughly gonna be the same as your performance hit for medium/high SS Shadow settings.
     
    ArtisticSliz and RB_lashman like this.
  30. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    @sonicether
    Just to be sure - should this post effect be placed above or below the standard post processing stack in the camera component list?
     
    RB_lashman likes this.
  31. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    502
    It seems logical that it would be applied before the stack, if not right at the top of the camera scripts. It is, after all, augmenting the lighting and shadowing Unity does and isn't an artistic filter.
     
    RB_lashman likes this.
  32. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    My project could really use some of your awesome screen space shadows :)
    Any hope of a Forward render version using command buffers on the directional light as an entry point?
    Deferred only makes sense for lots of point or spot lights, otherwise it's too heavy and has many disadvantages like being incompatible with multiple render targets and only having a single lighting type for materials.
    Deferred screen space reflections are cool but way too buggy and expensive to consider using them comercially.
    Because of this, I really think Forward render is the way to go and the only reasonable solution for me.
     
    RB_lashman likes this.
  33. guidoponzini

    guidoponzini

    Joined:
    Oct 4, 2015
    Posts:
    55
    Thank you for this amazing plugin. I'm using it for two applications that will run at an exhibition in Las Vegas in March 2017 and I'm so happy with it... Here you can find few early screens from one of the environments, more coming soon while I'm going on (here there are only mining environment work in progress setting, there will be machinery and components, then I will have also a totally different construction site with machineries and components).

    https://connect.unity.com/p/5857f46c090915003342358b
     
    sonicether and RB_lashman like this.
  34. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    It doesn't matter where you place the script on the camera, since it uses command buffers to apply the effect before any other post effects.

    I'm just finishing up work on updating another one of my assets, and then I'll look into it in more detail soon!
     
    buttmatrix, atomicjoe and RB_lashman like this.
  35. GLID3R82

    GLID3R82

    Joined:
    Aug 7, 2013
    Posts:
    10
    I want to know if the Screen-Space Shadows system
    works correctly only if I disable the hbao on my project...
    because I have to use Screen-Space Shadows and hbao together...
    is it possible to use them together?
     
    AlteredPlanets and RB_lashman like this.
  36. jdraper3

    jdraper3

    Joined:
    May 28, 2015
    Posts:
    117
    I use them together without any issues, and they look great.
     
    RB_lashman likes this.
  37. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @sonicether Hello, I started using this asset for Ghost of a Tale. If you'd like to use a screenshot:



    But I'm also writing because after doing a Windows build in 5.5.0p4 I got those errors:



    Would you mind taking a look at them please?
     
  38. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    No problem!
     
    Shodan0101, Seith and RB_lashman like this.
  39. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    I sent a message through your website but never received a response. I'm developing for the PS4 and XB1 and wanted to know if this asset would be compatible with one or both.
     
    RB_lashman likes this.
  40. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    I can confirm it works on Xbox One.
     
    RB_lashman likes this.
  41. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    Thanks Seith. The PS4 is my lead platform and the one I'll need it for first.
     
    Seith and RB_lashman like this.
  42. sonicether

    sonicether

    Joined:
    Jan 12, 2013
    Posts:
    265
    Sorry about that, I must've missed it!

    Since I can't personally test anything on PS4 or Xbox One, I can't definitively say for sure. However, I do have in mind the things that need to be avoided when writing shaders in order for them to work on those platforms, so there's a good chance it'll work on PS4. If it doesn't work and I ended up missing something, definitely let me know and I'll fix it as soon as I can!
     
    RB_lashman likes this.
  43. scheichs

    scheichs

    Joined:
    Sep 7, 2013
    Posts:
    77
    PS4 works out of the box.
    192.168.0.103-20170202-0047.png
     
    jdraper3 and RB_lashman like this.
  44. local306

    local306

    Joined:
    Feb 28, 2016
    Posts:
    155
    Picked this up today and ran the demo scene. Not sure why but static batching doesn't seem to be working and I'm getting like < 30 FPS on a GTX 980 + i7-6700K build.

    Anyone else experiencing this? Unity 5.5.0p4.

     
    RB_lashman likes this.
  45. local306

    local306

    Joined:
    Feb 28, 2016
    Posts:
    155
    PS I tried this package out with another scene using OpenVR via SteamVR and it worked great! No measureable impact on performance with or without the effect on for that particular scene.

    EDIT: Multi pass of course. Although single pass would be amazing too if possible!
     
    RB_lashman likes this.
  46. Fera_KM

    Fera_KM

    Joined:
    Nov 7, 2013
    Posts:
    307
    Hi,

    Is this suppose to be an upgrade to SE- SSAO? Or am I suppose to use both of them together?
    (I haven't bought this one, so I'm not sure what kind of options there are).
     
    RB_lashman likes this.
  47. Neo-Gamefactory

    Neo-Gamefactory

    Joined:
    Oct 18, 2012
    Posts:
    145
    Is it like AO?
     
    RB_lashman likes this.
  48. No0B25

    No0B25

    Joined:
    May 2, 2016
    Posts:
    70
    Nope, it's literally shadows for very small objects. You use it alongside AO.
     
    Neo-Gamefactory and RB_lashman like this.
  49. Neo-Gamefactory

    Neo-Gamefactory

    Joined:
    Oct 18, 2012
    Posts:
    145
    Perfect :)
     
    RB_lashman likes this.
  50. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    Hi sonic ether,
    I bought your asset, it's really great, thanks! It would be nice, if you could help me:
    What do I have to change when I'm using a custom shadow caster like "Sunshine!" ?

    I think, I have to set the shadowmap (or the Screenspace shadowmap?) of Sunshine in your Shader, the rest should be fine, however I don't know where to do that, maybe you could give me a hint?
    (Currently it's not working with Sunshine. Only when I turn off the Sunshine Camera Script it works..)

    Thank you,
    Best Regards

    Edit: As a workaround I just removed DisableBuiltInShadows (); in the Sunshine script.. but would be nice to know how it works when I disable the unity shadows and use only Sunshine's custom shadows?
     
    Last edited: Feb 9, 2017
    RB_lashman likes this.