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

Shadow Softener - Official Thread

Discussion in 'Assets and Asset Store' started by PolyVector, Sep 11, 2013.

  1. Airborn-Studios

    Airborn-Studios

    Joined:
    Oct 31, 2012
    Posts:
    30
    Hello i have one question about this asset, looking at the screens i assume your plugin "only" blurs the whole shadow, right? would it also be possible to have shadows beein sharp at their start and getting blurrier the further away they are from the shadow caster?
     
  2. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hiya,
    This (PCSS) has been requested a number of times, but unfortunately it's not currently possible. I'm not too impressed with PCSS in practice tbh, the penumbra artifacts are really distracting.

    Uniform filtering only, at least for the time being. :)
     
    Last edited: Oct 31, 2013
  3. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    1- yes more than ones
    2- its the same with all light types
    BTW i am using DX11 and linear color space
    latest unity pro
     
  4. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Okay, you're almost certainly on to the cause with DX11 and/or linear color space. I'm developing on a Mac, so the DX9 renderer is as far as I've tested. I'm going to have to see if one of our Macs can do DX11 or borrow a friends computer to fix this.

    Thanks for the info, I'll post more when I track down a solution. :)
     
    Last edited: Oct 31, 2013
  5. Pawscal

    Pawscal

    Joined:
    Mar 26, 2013
    Posts:
    11
    Hi there, Just got your plugin today and i've been messing around with it for an hour or so now. It seems really nice, but i can't get the shadow strength parameter to work anymore. Is it a bug or is it just normal behavior??

    using Unity Pro and deferred lighting.

    Thanx in advance for your reply.
     
  6. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hi Pawscal,

    Thank you for pointing this out... It does indeed appear to be a bug with Point and Spot lights. :oops:

    Directional lights appear to work properly with the strength setting, I'll try to address Point+Spot strength in the next release.
     
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @Pawscal

    Okay, I've managed to fix this in both the Forward and Deferred renderers for Directional+Point+Spot lights. Apparently Directional+Forward was the only combination that worked with the strength parameter.

    The next update should squash this bug that also addresses the GLES3+Directional incompatibility, but I need to do further testing before release... Hopefully I'll get this out to you guys by next Monday or Tuesday. :)
     
  8. Pawscal

    Pawscal

    Joined:
    Mar 26, 2013
    Posts:
    11
    Awesome! Thanx for your fast reply!
     
  9. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey all,

    Just wanted to let you know that Shadow Softener 1.2.2 has been released!

    GLES3 support has been added, so Directional, Spot, and Point filtering should work on newer mobile devices. Please keep in mind that mobile devices should use a small filter kernel (PCF4x4 is pushing it) or performance will suffer.

    The Shadow Strength parameter now works in almost all cases. (The only exception is Forward Rendered Directional lights on GLES3... I'll try to fix this in the next release)

    Enjoy!
     
  10. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sorry this has taken me a while... I managed to get Windows 8 installed on one of our Macs that supports DX11... Put Unity into DX11 mode and tested Shadow Softener extensively.

    Everything worked with Directional, Spot, and Point in both Forward and Deferred renderers, with both Gamma and Linear space lighting.

    Is it possible you've edited the deferred config file to something that won't compile? If you've edited it, maybe you could paste the config file here or PM me? :)

    Also, when you say it's not working, do you mean shadows don't show up, or are they just not soft? A screenie might help me sort this out faster if you get the time. :)
     
  11. robot-ink

    robot-ink

    Joined:
    Jul 1, 2011
    Posts:
    18
    Great package, thanks!

    question: I wrote a shader for collecting shadows on a transparent surface using vertex and fragment programs... is it possible to somehow use shadow softener on it? I've been trying to somehow combine the output of my frag shader into a surface shader but my shader-fu is not strong enough. Or alternatively, is there a way to get the softened shadow strength value out of the surface shader?
     
  12. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks! :)

    Shadow Softener is supposed to automagically soften the built-in shadows, so the first requirement would be getting the regular built-in shadows working with your vert/frag shader.

    If you have shadows working, but they aren't being softened by Shadow Softener, PM me the shader and I'll investigate possible solutions for ya. :)
     
  13. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    Any update with DX11 and deferred lightning?
     
  14. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I tested DX11 a couple weeks ago and everything worked fine on my computer.

    Here's my post again: :)

     
  15. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    437
    Hello there. Got errors when i set #define SOFTENER_FILTER PCF4x4 higher then 4x4. If i set 5x5 (any type of lights) for example, all shadows gone and 2 errors in log:
    --------------------------
    Shader error in 'Hidden/Internal-PrePassCollectShadows': Program 'frag', Constant register limit exceeded; more than 32 constant registers needed to compiled program at line 20

    Keywords: SHADOWS_NATIVE, SHADOWS_SPLIT_SPHERES
    --------------------------
    ---------------------------
    Shader error in 'Hidden/Internal-PrePassCollectShadows': Shader program had errors at line 22
    -----------------------------

    im working in dx11, win7, linear space color. its happening every time. in fresh project.
    and the second. i would like to move folder with softener to another subfolder, but i cant do that without errors too =(
     
  16. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    The errors seem to be a problem that started with the new version of Unity. I'll investigate this and see what can be done.

    If you move the folder, this will cause problems for the Shader Converter, and any shaders you have that might reference ShadowSoftener.cginc. It's best to keep it in it's default location.
     
    Last edited: Dec 4, 2013
  17. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @zelmund

    I actually found a few issues with Unity 4.3 compatibility, specifically with Deferred+Spot support and the constant registers maxing out as you've noticed.

    I've updated Shadow Softener to address these issues (Current version is 1.2.4). Try updating your copy when you get a chance, you should be able to go over PCF4x4 now. :)
     
  18. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Shadow Softener 1.2.4 is up on the Unity Asset Store
    • 1.2.4: Fixed Unity 4.3+Deferred+Spot lights. This does however break Unity 4.2+Deferred+Spot support since it now relies on the new _LightAsQuad parameter
    • 1.2.3: Moved many PS calculations to VS in Internal-PrePassCollectShadows to reduce constant register usage.

    We also noticed our downloadable demos were having a compatibility issue, so if you were holding off purchasing Shadow Softener, or Sunshine, please check out the demos and hopefully you'll get to see our tech the way it was meant to be. As always, we are here to answer any questions.
     
  19. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Someone just pointed me this way as they liked a video i did and said this might help with one of the artifact problems. I really like this, and i'll see if I can get some money together for it eventually, i am, afterall, trying to make a 'unity is da bestest!' video so i need all the help i can get aha.

    An earlier comment in this video talked about shadows with penumbra regarding Sunshine, ive also looked at that, and it looks very good, and if you could implement some kind of contact hardening shadows i would buy it, in fact i would feel stupid for not buying it, while in harsh light shadows are meant to be sharp, thats direct sunlight for yo -, but if there's a reason for shadows to be scattered and there often is, that would be a must buy for me assuming I could gather the funds (im sure others would buy it anyways), there are papers for it, and iirc an article in one of the gpu pro books which i could try to find for you. Actually i think all 4 gpu pro books have sections on shadows and you'd be joining the hall of unity heros by having a serious look at your own implementation of them. You'd also, genuinely, become incredibly rich, if that helps!

    Either way, i'll keep this asset in mind for future and if sunshine can offer what i suggested regarding shadow definition then i'd take up busking to gather some money for it, i have a beautiful singing voice that my city would love to hear. I'm not that fussed about 'atmosphere' or volumetric kind of things though, unless they will integrate reasonably with the other tools im getting together

    One additional point, i'm currently using forward rendering as, for some reason its proving faster than deferred at the moment, and i understand it better, this raises the issue of using RTP with your products that automaticaly update shaders as RTP regularly rebuilds its shaders with a manager as ones needs change (but would be like a very happy pig in S*** with some smooshy lovely shadow lovin) - it also uses addpass pretty normally as you might imagine. If that's an issue maybe you could have a word with Tomas the creator about it

    err, rtp is the terrain thing, in case you didnt know
     
    Last edited: Dec 5, 2013
  20. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hi Lazygunn,

    Glad to hear the word is getting out there, hehe. :)

    The variable penumbra sizing you're refering to is generally known as PCSS or Percentage Closer Soft Shadows. I've attempted implementing them in Shadow Softener, but hit Unity limitations that prevent it from working correctly. It's theoretically possible to do in Sunshine, but I it would mean giving up the soft PCF filtering for something more like Poisson Disc Filtering (which is the basically the noisy filtering Unity uses). I plan on investigating PCSS more with Sunshine in the future, but I make no promises.

    Sunshine is primarily useful if you want Volumetric Light, Tegra 3/Ouya support, or games that are bound by fill rate (since it's much lighter on fill than built-in). Shadow Softener is best if you want a wide variety of soft lights (point/spot/directional) or crazy-soft shadows like PCF8x8.

    Shadow Softener should work fine with RTP, the creator of that asset had this to say about Shadow Softener in his support thread

     
    Last edited: Dec 6, 2013
  21. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hah nice! Well there's quite a few shadow techniques i've looked at (for instance what you call pcss i've seen called contact hardening but i guess the semantics are the same) - if you're at all interested I can go see what I can dig up from my gpu pro book stuff (theres possibly 10+ shadow techniques in the series) so you might find some value in it and the funny secret story to it all is all the source is freely available from the publishers website, you actually barely need the books! (if at all)

    I'm going to look purely out of interest now but i wont clog up your thread unless youre interested/or dont already know of it or i could send you a PM with anything i find relevant. Also I need an excuse to get off the sofa and back to work so there we have it
     
  22. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for the links/suggestions. I'll read over them when I get the chance. :)
     
  23. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    Found out why shadow softener doesn't run on deferred on my project
    its a compatibility issue with the asset GameDraw. there is no errors in the compile but the shadows simply will not work.
     
  24. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    That's strange. Is GameDraw using custom shaders for objects/materials it creates?

    If you'd like me to investigate this further, PM me a scene you're having problems with and I'll look for a workaround. :)
     
  25. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    671
    Have 1.2.3 handy? Updated to 1.2.4 just now and it busted my Deferred lighting in 4.2, and 4.3 has too many lingering issues. Who do I PM my invoice? Thanks.

    Edit: Actually, just remembered that Unity doesn't destroy the old package, but instead sends it to the Recycling Bin, so I was able to retrieve it and re-install.
     
    Last edited: Dec 12, 2013
  26. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It was really unfortunate that I couldn't leave in support for both 4.2 and 4.3, but shaders don't appear to have specific version macros to check for, at least not that I can find(?). Maybe I'll add a macro in the next version that you can uncomment to support 4.2.

    Glad you got it working though. :)
     
  27. germ

    germ

    Joined:
    Oct 21, 2013
    Posts:
    2
    Hey there. I've been playing with Shadow Softener. While I'm pleased with the ease of use, I'm having some unexpected results and I might not be "getting it."

    I'm using free Unity, and so I followed the "Forward Setup" instructions. I downloaded the original "Mobile - Bumped Specular" shader source, imported it, and then made a "softer" version of it. I set the light shadows to be hard. When I run it in the editor, I see this:

    $editor-shadow.png

    ... Which is okay. The edges are softer. There is a little diagonal banding, which I don't quite understand, but let's go with that for a second. :p

    When I run it on the iPad, I get this:

    $ipad-shadow.png

    ... Which is obviously less good. ;-) The first thing that came to mind is the shadow map size, but the detail is turned way up. Also there is that banding thing going on, which is worse than the original.

    I'm pretty new to Unity and I'm not really a 3D game programmer. Any thoughts on this? Thanks.
     
  28. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hi germ,

    That looks to me like shadow acne from the per-sample biasing, so you could try turning down the light's shadow bias.

    Since you're on mobile, and performance is everything, you might consider disabling per-sample biasing completely in the shader. You can do this by adding the following line before you include ShadowSoftener.cginc:

    Code (csharp):
    1. #define SOFTENER_SAMPLE_BIAS_OFF
    Let me know if either of those ideas help mitigate the problem. :)
     
  29. bigzer

    bigzer

    Joined:
    May 31, 2011
    Posts:
    160
    Hello PolyVector,

    In our project we use 2 cameras one in Deferred (world) and one in Forward (weapon).
    When I look at the weapon shadows they look really bad, I suppose I need to modify the shaders to fix that.

    Question;
    1. If I add the forward rendering shader modification, will the same shader still work correctly in Deffered?
    2. Will this affect the performance of the deferred rendering?

    I know we could have two materials with each its own dedicated shader but if possible I'd rather avoid that.
     
  30. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You should be able to add Forward support to a shader without affecting Deferred support or performance. :)

    Remember to try the included shader converter (in the Tools menu) since it usually does a good job upgrading shaders without having to look at any code. :)
     
  31. bigzer

    bigzer

    Joined:
    May 31, 2011
    Posts:
    160
    Awesome thanks :D
     
  32. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Edit: all resolved ;)
     
    Last edited: Jan 10, 2014
  33. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Haha, I'm glad you were able to sort it out. :D
     
  34. tbelgrave

    tbelgrave

    Joined:
    Jul 29, 2006
    Posts:
    321
    Absolutely impressive plugin, and the fact that it works with Unity Free just gain you a sale... Awesome support as well!
     
  35. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks! Let me know if you run into any problems. :)
     
  36. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hey there, I was wondering if you had a look at Shader Forge (a fantastic new tool that makes creating shader a cinch: http://forum.unity3d.com/threads/222049-Shader-Forge-A-visual-node-based-shader-editor). I've tried manually applying the fix in the Shadow Softener doc to add soft shadows to forward mode shaders but it doesn't seem to work; the shadows are definitely not smooth.

    Of course I first tried using the tool you included to convert the resulting Shader Forge shaders but got this message:

    Shadow Softener: Cannot convert "Assets/SF_POM_dual.shader"
    UnityEngine.Debug:Log(Object)
    ShadowSoftenerConverter:GenerateSofterShaders() (at Assets/Shadow Softener/Scripts/Editor/ShadowSoftenerConverter.cs:77)
    ShadowSoftenerConverter:OnGUI() (at Assets/Shadow Softener/Scripts/Editor/ShadowSoftenerConverter.cs:57)
    UnityEditor.HostView:OnGUI()


    Do you think it would be possible to make Shadow Softener compatible with Shader Forge shaders? I honestly don't know who should adapt to whom but being a customer of both your assets it would be great to have them playing nice with each-other. And the Shader Forge developer is a very nice guy too, so I hope this can happen... :)
     
  37. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    My only experience with Shader Forge is getting one User's shader to work with Sunshine.

    The automatic converter doesn't yet support vert/frag shaders, just surface shaders right now. I'd like to add support in one of the next releases if it's possible and I get some free time. :)
     
  38. Deleted User

    Deleted User

    Guest

    Is it possible to make Shadow Softener work with RTP v3 in Forward mode? I tried to convert the ReliefTerrain-FirstPass shader with the supplied automatic converter, but I received the following errors and warnings in the generated shader:

    $RTP.jpg

    Can this be solved?

    Thanks a lot!
     
  39. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It's hard to say without seeing the shader, but it sounds like you need to target SM 3.0 by adding this:
    Code (csharp):
    1. #pragma target 3.0
     
  40. Deleted User

    Deleted User

    Guest

    That line is already in the code. :( Any other idea?

    Thanks anyway!
     
  41. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sorry, not without seeing the code. :/
     
  42. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I tested softener on RTP and it works. Just needed to follow instruction.

    addshadow directive in pragma of first pass (you don't need it for addpass) of terra shader, then right ater #include "UnityCG.cginc" put

    // filter level required
    #define SOFTENER_FILTER PCF4x4
    // Include Shadow Softener
    #include "../../../Shadow Softener/Shaders/ShadowSoftener.cginc"

    above path for ShadowSoftener.cginc is set assuming that shadow softener is placed in assets folder just like ReliefPack folder of RTP.
    I tested this compiling RTP for DX9. Maybe that's the issue ? Which target platform you're trying to use ? It's also good to know that you need to put softener only on main subshader of first pass. There are fallback subshaders where you don't need to use make any changes.

    You can give me your not working shader code via PM so I can take a look.

    ATB, Tom
     
  43. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Anyway - glad to look into the issue because incoming RTP3.1 uses custom shadow passes and using Softener in forward path with this would be different. I just put in firstpass shader code commented out part. Uncommenting this will bring softener functionality for RTP.

    ATB, Tom

    P.S. Softener is cool :) (learned much about shadow system analysing its cginc code)
     
  44. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for the help Tom. :)

    I've been swamped with with work lately and haven't had much time for support.

    Hehe, glad you like the project... it's unfortunate that Unity's shadows requires such extreme measures to extend though.
     
  45. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    OK, SeanM3D reported me that PM that it now works for him (and I must admit soft shadows on the RTP terrain is another gift)

    Tom
     
  46. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    That's excellent! Thanks so much for getting him sorted out, I appreciate it. :)
     
  47. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    671
    @PolyVector

    Just curious if the latest version now supports 4.2. Please advise!

     
  48. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Right now the only change between the last two releases was the 4.3 compatibility tweak, which is 2 lines of code. :)

    The next release will contain a macro that allows you to enable 4.2 support by disabling the tweak.
     
  49. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    671
    Thank you. Looking forward to this.


     
  50. edux404

    edux404

    Joined:
    Feb 14, 2014
    Posts:
    5
    Hello, this may seem dumb, but I don't have any idea on how to use it, I read the documentation but no help. So, can you explain me? Sorry for noobish :|