Search Unity

Shadow Softener - Official Thread

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

  1. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Ever wish your shadows were, ya know... Softer? :oops:

    Well this is the Official Support Thread for Shadow Softener, a package that makes your shadows incredibly smoooooth!

    If you run into any problems, just let me know and I'll do my best to sort it out. ;)
    • Works with Unity Free or Pro!
    • Customize Directional and Spotlight filtering!
    • Beautiful PCF filters, up to 8x8!
    • Write Custom Filters! (sample included)
    • Works in Forward and Deferred renderers!
    • Works with Shader Model 3.0 and above.
    • What are you waiting for!?
    [Asset Store] [Documentation] [Webplayer] [Mac Demo] [Win Demo]






    Check out what others are doing with Shadow Softener!

    (Courtesy of nukeD)
    [video=youtube_share;kTJLd2MxRFY]http://youtu.be/kTJLd2MxRFY
     
    Last edited: Oct 25, 2013
    Lex4art likes this.
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    What is the performance of these PCF based shadows compared to the normal hard and soft shadow (2 4 cascades)?
     
  3. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    I couldn't help but notice that you said it works with Unity free. Haha, Unity free only has hard shadows, so are you saying that I can have BETTER soft shadows than pro?
     
  4. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    I think he was talking about better hard shadows, but if he wasn't then :D

    Also an online demo would be good.
     
    Last edited: Sep 12, 2013
  5. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Well then again, shadows do exist in Unity free now, therefore the code is there to be customized. :)


    Edit: I think its REALLY important that you make a simple web demo. I need to know the soft shadows work in Unity free and perform well enough.

    Thanks in advance.
     
  6. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey guys, sorry for the delay!

    I don't have exact numbers since there are a lot of variables (PCF kernel width, light type), but I'll try and put a demo together this week that compares them with FPS. :)

    Yes! I am totally saying that!
    Of course, it will only work with the single Directional Light they allow you to cast shadows with. ;)

    Agreed! I'll try and put one together this week!
     
    Last edited: Sep 12, 2013
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I should probably clarify that what Shadow Softener does is customize the way Hard Shadows are sampled before the built-in "Soft" filter takes effect.

    This is why it works in Unity Free. :twisted:

    It's also why Unity Pro's fuzzy "Soft Shadows" filtering can still be enabled on top of Shadow Softener's result. Although I'm not sure why you would do that! ;)
     
  8. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Sounds awesome. Another question. I'm not much for coding shaders. Would be really nice if you could post(even on here) spec-bumped shader and a spec-bumped shader for terrain that work with your soft shadows. :)
     
  9. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Here's the built-in TerrBumpFirstPass.shader, modified with PCF8x8. Everything in BOLD was added, which is mostly just comments because the process is very simple! I just tested this shader, btw, and it works flawlessly. ;)

    If you ever buy Pro and use Deferred Rendering, none of this is necessary... It just works!

    Because the Terrain shaders use both a Base and Add shader, you would want to do the exact same thing to the TerrBumpAddPass.shader version referenced by the Dependancy at the bottom... Terrain/Tree shaders are pretty much the only time you'll run into this sort of thing... Most shaders are one-off. ;)

    The Documentation goes over most of this in more detail!
     
  10. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey everyone!

    There's been a lot of questions about the differences between [Shadow Softener] and [Sunshine!], so I thought I'd attempt to clarify here:

    Shadow Softener:
    A system to control the way the existing built-in shadows are sampled.

    Pros:
    • Support for any number of Directional and Spot lights.
    • Support for Unity Free (they allow shadows on a single Directional Light)
    • Support for up to PCF8x8!
    • Support for Custom Filters
    • In the Forward Renderer, you don't have to edit every shader, you can simply tweak shaders you feel could use extra soft shadows (floors/walls). Sunshine is more of an all-or-nothing system. If you use the Deferred Renderer, it's all automatic, just like Sunshine. ;)
    Cons:
    • Only runs on platforms where the built-in shadows already work, so no Ouya support.
    • Large PCF kernels often run into "Shadow Acne" problems, but I'm using some per-sample bias trickery to eliminate it as much as possible.
    Sunshine
    A shadow implementation that's completely separate from the built-in one, yet tries to match settings/behavior as closely as possible.

    Pros:
    • Has access to all shadow data, to do things like Volumetric Lighting... I have plans to explore other effects as well, I've just been too busy adding requested features!
    • Has a great Overcast Shadow effect. This is better than any "Light Cookie" thing built-in. It blends nicely, and uses a virtual "cloud plane" with adjustable height for calculations.
    • Up to PCF4x4 filtering.
    • Can run on normally unsupported platforms like Ouya/Tegra 3 devices
    • Control over when the shadow map should be refreshed (ie. after X frames, or after the camera moves X amount, even manually).. Great for Mobile
    • Control over the shadow bounds... so you can have it match your main character, using a low 128x128 shadow map can be more than enough... Also great for Mobile.
    • Many little niceties like MSAA-friendliness, Alpha objects that can cast cutout shadows, etc.
    • Reduced Fillrate - One of the reasons I wrote Sunshine is I was working on an app that would slow down with built-in shadows because it ran at a high resolution and the extra "collector" pass was too much fill. Sunshine has no "collector" pass. ;)
    Cons:
    • Only works with a single Directional Light
    • Requires changes to shaders if you use the Forward Renderer (Deferred is automatic), but pretty much every built-in shader is already edited for you, and Sunshine will automatically swap them in/out as you require.
     
    Last edited: Sep 12, 2013
  11. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey Everyone!
    Just got a demo up (Web/Mac/Win) to demonstrate quality vs. performance!

    Keep in mind the Unity Webplayer is limited to 60fps. ;)

    [Webplayer] [Mac Demo] [Win Demo]
     
  12. Jimmy3d

    Jimmy3d

    Joined:
    Nov 20, 2012
    Posts:
    13
    This is creating BEAUTIFUL shadows in my scene!

    Somehow several of the shaders on our "Tree Creator" trees have turned grey. Has anybody come across this problem??

    Image attached, thanks ahead.

    $shadowsButGrayTrees.JPG
     
  13. BIG-BUG

    BIG-BUG

    Joined:
    Mar 29, 2009
    Posts:
    457
    Wow, those look nice. 4x4 PCF is a nice compromise to get rid of the ugly jagged edges.
    One question remains: Why isn't this available in vanilla Unity?
     
  14. BIG-BUG

    BIG-BUG

    Joined:
    Mar 29, 2009
    Posts:
    457
    Double Post
     
  15. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Really impressive work!!! Thank you from Free.
    That and indie glow and I have most of what I need from Pro.
    Great job.
     
  16. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    Already in my to-buy list :D
     
  17. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    *oops* (reposted below, I meant to edit this one :oops:)
     
    Last edited: Sep 12, 2013
  18. Jimmy3d

    Jimmy3d

    Joined:
    Nov 20, 2012
    Posts:
    13
    I just remembered that I also imported JXL Rendering tool at the same time, I'll look into it on my end.
    Cheers,
    jimmy
     
  19. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Glad to hear you like the shadows!
    Strange about the "grey" issue, I haven't run into this before. If you send me a project that reproduces it, I'll investigate. :)

    Just going out on a limb here, but we might have stumbled onto a government coverup perpetrated by the NSA! :eek:

    I aim to please! :cool:

    Yes, follow your heart! :mrgreen:
     
  20. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sounds good. Just let me know if there's anything I can do to help. :)
     
  21. Djiel

    Djiel

    Joined:
    Jun 25, 2012
    Posts:
    108
    Looks great. This should be in Unity by default, the vanilla shadows are horrible.
    On my to buy list as well.
    To be honest I was hoping for a little bit lower price, but it's a must have.. :)
     
  22. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    Looks great, would be nice if the price was a bit lower though.
     
  23. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    What would you two suggest as a fair price? :)
     
  24. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    $25

     
  25. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Looks very interesting, do you have an idea if it would be possible to have the shadows sharper where objects are closer to the surface the shadows are cast onto. I mean harder at the contactpoint and softer with distance... that would rock even more :)
     
  26. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Just want to say. I purchased this package. I am blown away man, great job. I am extremely excited to have better soft shadows in Unity free than in Unity pro!

    Good job. On a side note, if you could figure out how to integrate this to work in forward rendering with any shader without adding code, it would be far more convenient. :)
     
    Last edited: Sep 14, 2013
  27. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937

    I have an issue with the terrain shader you provided. It says "Shader error: include fall back failed at line 36"

    I know pretty much nothing about shader scripting, so I would appreciate having my hand held until I have this terrain shader. :)
     
  28. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You probably want something like PCSS (Percentage Closer Soft Shadows). This should be possible to achieve, but I've never tried it to be honest... Maybe I'll experiment with the technique some time. ;)

    Wouldn't that be great!? If Unity ever adds some kind of Shader Asset Processor or ShadowMap API that can be hooked into I'll be all over that! :)
     
  29. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    The #Include path is relative to where you place the terrain shader. ;)
    It would be great if Unity would search your project for cginc files, but c'est la vie!
     
  30. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
  31. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    *facepalm* I'm on my tablet right now, I totally misread what you said! I think you forgot to create the other Dependent shaders. :)

    I think you need to either create a Specular too, or set the dependency to the built-in "Specular"
     
  32. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Yeah I figured it out. I took a look at Unitys source. Thanks. :)
     
  33. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    hi,

    impressive work:eek:

    Can work with DX11?

    Dev
     
  34. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I've never used the DX11 renderer (I'm on a Mac, and I don't think DX11 can run virtualized)...

    The whole thing is designed for SM3.0, so DX11 should be able to run it... As to whether or not the new DX11 renderer changed the way shadows work is outside my expertise. ;)

    Edit: If anybody can confirm DX11 support, that would be awesome!
     
    Last edited: Sep 14, 2013
  35. stevenapolo7

    stevenapolo7

    Joined:
    Aug 15, 2012
    Posts:
    24
    Hi, i´m really interested but i´m using Unity Pro 3.5.7, will it work?
     
  36. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Unfortunately I built the project in Unity 4.x, so I believe the Asset Store will require 4.x to download. There's no reason it can't work in 3.5.7, though it may require a tweak or two, I'll put it on my TODO list. :D
     
  37. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    How did you manage to get the built-in hard shadows in the demo this ugly?
     
  38. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm not sure what you mean, they're simply the built-in hard shadows? Maybe if you post a screenshot, I can see what you're talking about.

    On some platforms the GPU gives free PCF2x2 with "Hard" shadows, and on some platforms it does not... I don't believe you can control that one way or the other.

    The resolution is low, of course, to help visualize how the different filters look.

    Edit:
    I should have specified that my comparison screenshot includes both "Hard" and "Native" to visualize how "Hard" shadows look on platforms with and without the free hardware PCF I mentioned earlier.
     
    Last edited: Sep 20, 2013
  39. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    Did you set them to the lowest possible resolution? They're horribly jagged
     
  40. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hehe, as I said the resolution is low to show the different filters clearly, and all filters are running at the same resolution for fairness.

    Again, in the comparison screenshot:
    • Built-In "Hard" - Completely ordinary "Hard" shadows on a GPU that doesn't natively support PCF. I believe that in Unity 3.5 ALL Hard shadows look this way, at least they do on my Mac.
    • Built-In "Native" - Enhanced "Hard" shadows in Unity 4.x on a GPU that supports native PCF. This might be what you're used to seeing.
    • Built-In "Soft" - The "Soft" shadows we all know and love.
    • PCF Filters - An assortment of Shadow Softener filters.
    I hope this helps in your quest for terrible shadows. ;)
     
    Last edited: Sep 21, 2013
  41. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    The softened shadows look waaaaaaaaaay better though

    If you use a higher shadow resolution, will the blurred area get smaller?
     
  42. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Correct, the blur is measured in shadow texels, so PCF 4x4 will blur 4x4 shadow texels... How big those texels are physically is based on the Resolution, shadowDistance, and Cascade Count.

    A goal with soft shadows is to avoid the need for extremely high resolutions in the first place, which affords you the ability to use a higher shadowDistance, or Cascade Count. :cool:
     
    Last edited: Sep 21, 2013
  43. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    hmm this is tempting! :) However I know nothing about shader programming, so it seems risky to use this plugin.
    I`m using the T4M Source Code edition Shader Model 2: 4 Textures Bumped shader for my terrain mesh. I had to fall back to that one because the SM 3 version turns all colorfull on my Surface Pro as in mostly green and blue and pink really.
    So if you have the T4M plugin could you test please if your modified terrain shader works properly with it?

    PS: Do I understand it correctly that I only have to edit the shaders of the objects where the super soft shadows should be casted ON?
    For my game it would pretty much be that terrain shader and then the default bumped diffuse shader that need replacing, so that would be doable.
    If I also have to edit the shaders on the objects where soft shadows should be casted FROM that would probably get messy as it's lots of trees/foliage.
     
  44. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I don't have T4M right now, so I can't comment on compatibility... Generally though, if it works with built-in shadows it can be made to work with Shadow Softener, provided there are enough free instructions for the filter you're using.

    You're correct, only objects that need to receive extra soft shadows must be modified, nothing changes for shadow casters. :)

    Of course, if you're using the Deferred Renderer nothing needs modification, and everything becomes softer. ;)

    Right now Shadow Softener filters require SM 3.0, so that would be a problem if you're targeting Mobile/SM2.
     
  45. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Can anyone tell me if it works with Etherea please? :confused:
     
  46. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    Please say you will support point lights :(
    i thought my life is complete...
     
  47. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Shadow Softener merely modifies the way built-in shadows are filtered. From reading over the Etherea thread, that package doesn't support shadows at all, so I would have to assume that it is not compatible.

    Point Lights are something I'm interested in exploring in the future if there's enough demand for it. The reason they aren't currently supported, is they would require a completely separate set of filters, since the 2D PCF math doesn't translate well to their 3D coordinates.
     
  48. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Thx for the reply.
     
  49. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey Everyone!

    Shadow Softener 1.1 is live!
    • Added support for Unity Pro 3.5.7
    • Improved Deferred Directional Shadows can now use any filter, even PCF 8x8! :)
    GET. IT. NOW.
     
  50. bigzer

    bigzer

    Joined:
    May 31, 2011
    Posts:
    160
    Hi, just bought your package and it seems to look fine however we are using marmoset shaders almost everywhere and as I expected they do not support your softshadows out of the box (all objects look black).

    Any chance to get some kind of support to make it work?
    Marmoset and the advanced surface shader packages are the most popular shader sets available, supporting them basically means supporting 80% of the shaders used out there.