Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Unity 5.0 and Variance Shadow Mapping

Discussion in 'General Discussion' started by Jes28, May 26, 2014.

  1. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    261
  2. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    VSM (and variants like EVSM etc.) are not planned for 5.0. But we are aware that we should improve shadow filtering somehow. Just won't happen in initial 5.0 release, I think.
     
  3. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,064
    And what about PCSS?
     
  4. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    Same answer. No significant improvements in how shadow filtering is done out-of-the-box in 5.0.

    (we have changed how shadows in forward rendering are done - e.g. they do not require "re-render whole scene with shadow collector pass" thing anymore... but it does not change how the shadows are filtered)
     
  5. Matt-Ostgard

    Matt-Ostgard

    Joined:
    Jul 23, 2012
    Posts:
    3
    Aw.. Very sad to hear. I was just comparing Unreal 4's real-time shadows to Unity's and it's a big difference in quality. I'll be excited when you guys get a chance to work on it though.
     
  6. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    In the meantime... you could always do more filtering taps if you're willing to write your own shaders or hijack AutoLight.cginc :)
     
  7. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,297
    Doesn't Enlighten bring some shadow improvements? Or will it still use Unity's standard shadows?
    Maybe i'm confused with what new things Enlighten brings to the table, besides real-time global illumination and new lightmapping.
     
  8. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    546
    Since we're talking about shadow techniques there's something I've been meaning to ask, I've been having to deal with shadow performance and stuff lately and mind you I have no clue how this stuff works in the background so forgive my ignorance...
    But I've been wondering, if deferred lighting basically allows us to have a large number of lights with really good performance, is there some sort of equivalent for shadows? Deferred shadows so to speak. Or maybe that's already a thing? (again, I have no idea and I'm probably butchering how this stuff works lol). I'm just wondering because it seems like it would be a natural progression of deferred lighting (like if you can have near unlimited lights, makes sense to be able to have near unlimited shadows).

    In my game BHB I have scenes where I use a large number of dynamic lights and I get really good performance. But where turning a couple of lights on/off doesn't change performance much, turning a couple of shadows on/off does and I'm wondering if there are any techniques out there that would allow for large numbers of dynamic shadows. Again, pardon my ignorance on the subject but I've been really interested in knowing. I've been able to fake it really well using cookies for a lot of stuff, but there are many cases where dynamic shadows would be more desirable.
     
  9. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    790
    You have "unlimited" shadows in your shadow range. If you want to increase that range, you basically have to render more and more objects so it gets slower. But the option is existent...

    You can always decrease your light power.
    If you have a grid of objects with a distance of one unit and one light with a range of one unit, every light has to affect 5 objects at most.
    If you increase the light to 2 units, you will get to 12 affected objects.
     
  10. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    A question for all of you: how would one go about modifying the shadow maps, or even accessing the tex?
     
  11. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    546
    I'm well aware of all that. And what I'm talking about is mainly performance related, if you reread my post you'll see that I mention that it does get slower and that's my point. I already have workarounds and can get the look I want though, so it's not a matter of me being stuck or complaining or anything.
    With deferred lighting, the performance cost is based on how many pixels are being lit, which means you can have many lights for relatively cheap performance-wise.
    What I'm asking (and I guess I should have specified that I was asking Aras) is if there's some sort of equivalent for shadows or if such a technique even exists or is possible (not in Unity, but technology in general). Because currently while we get great performance with lights, we don't have similar boosts (to my knowledge) with shadows. What I'm asking is more theoretically than anything else but I wanted to get Aras's thoughts on that since we're talking about shadows
     
  12. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    Enlighten does not do anything with shadows (nor any direct illumination). It only computes provides the indirect lighting (2nd and later light bounces) and indirect specular. And baking of lighting offline, if you wish. All direct lighting shadows are completely outside of what Enlighten does.
     
  13. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    There is some research into these kinds of algorithms, but nothing "production ready/proven" yet, as far as I know. e.g. this paper is pretty cool: efficient virtual shadow maps for many lights
     
  14. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    11,337
    For bakes? A folder with the maps gets created alongside the scene during the bake process. Then you can just use/access them as normal textures if you want, including opening them in an image editor and messing with them.
     
  15. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,656
    @angrypenguin,
    I think he mean dynamic shadows = "shadow maps".

    @FuzzyQuills,
    I've posted a while while back a custom AutoLight.cging that adds 8-tap filtering to Unity shadows (to smooth them a bit more) but I don't have the link right now, make a forum digging search! ^^
     
  16. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,318
    Ohh...please do it man..
    I need to know how to improve shadow filtering

    At least you guys aware about this issues, so i hope we got better shadow sooner :)
     
  17. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,656
    I have to dig the forums, I posted it a while back (back to 3.x) you probably don't want to use it entirely in v4 (I mean don't add it straight to your project) get only the 8-tap filtering part and add it to the latest AutoLight.cginc (v4).
    In the mean time there's an asset store package that will help improve shadows too (dunno the name of it though).
     
  18. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,297
    thanks for the clarification. I guess i was mostly wrong about what it would bring to Unity.
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,318
    it would be no problem, at least i know how to add custom shadow filtering...
     
  20. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    2,631
    If this can be done then it should be a part of the out of the box toolkit and implemented in a class of shaders. If it is a performance hit for some give us a checkbox or similar to toggle it off or on.
     
  21. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    The asset is here https://www.assetstore.unity3d.com/en/#!/content/11102 i'm told it's extremely good although i haven't tried it myself

    It makes slight alterations to your shaders which it can do automatically or you can do it yourself. I'm told it's much more visually pleasing and better performing than Unity's own soft shadows
     
  22. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    546
    Awesome that's exactly the sort of thing I'm interested in, thanks for that!

    This is me just thinking aloud and brainstorming but if I remember correctly Unity 5 will be using PowerVR's tech for the new lightmapping system...could that potentially be a possible avenue?
    I mean like using the hybrid raytracing for just the shadows but rather than limiting it to the editor for lightmaps actually using it in-game in real-time? Or would that still face similar performance scaling as shadowmaps and having many objects? I imagine there'd be a big initial performance hit but could that maybe work as an equivalent to deferred? (I'm thinking a few years ahead when consumer level GPUs are more powerful).

    I'm thinking about the stuff from this article here
    http://blog.imgtec.com/powervr-developers/implementing-hybrid-ray-tracing-rasterized-game-engine


    Thanks for your answer by the way, appreciate it!
     
  23. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,572
    Forgive my ignorance but what filtering are you using at the moment? PCF?

    I hear good things about VSM, is there a reason as why you wouldn't impliment this, besides manpower?
     
  24. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    Spot Point ligths use very small amount of PCF samples (4). Directional lights are filtered in screen-space using a rotated poisson disk fitler (http://aras-p.info/blog/2009/11/04/deferred-cascaded-shadow-maps/).

    Vanilla VSM has quite a lot "light leaking" issues (EVSM fixes many of them). Otherwise, they do require using two-channel floating point render targets, so use more bandwidth, have higher hardware requirements etc.

    My personal wish is to somehow make shadow mapping more extensible. I.e. by default we should provide some sane (better than now) filtering, e.g. 9-tap PCF (5x5 texel footprint can be achieved by carefully placed 9 PCF samples) or something. But if someone wants EVSM or something like that, they should be able to do that somehow.

    ^ none of the above is in immediate plans, but it is a recurring thought in the graphics team.
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,318
    Better PCF shadow filtering is good enough i think (so maybe we can choose between rotated filtering or not), and also i've tried some VSM and EVSM demo some of them are kinda heavy in performance
     
  26. Jes28

    Jes28

    Joined:
    Sep 3, 2012
    Posts:
    261
    Cool news. Hope this will be done in near 5.x release. :)
     
  27. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,101
    Honestly, the main thing I want isn't to replace the current shadowing technique with a different shadowing technique, but more to get away from the 'single unified approach' taken to shadows at the moment; I don't think there's any one technique that is going to be the best choice for all the shadows in my game. The current shadow approach works OK for my character shadows, for example - because the characters are moving, and because if they're close enough to see their shadows then the player will be focusing on them rather than the shadows anyway - but it's bad for my vehicles, which have very detailed silhouettes and are stationary a lot of the time. So what I really need is something whereby I can use high-quality shadows for the vehicles, but a faster/lower-quality approach for the characters.

    Maybe I should revisit this with stencil shadows in mind, hmm...
     
  28. jmatthews

    jmatthews

    Joined:
    Jul 27, 2011
    Posts:
    199
    Somebody in this thread has been working with fat G-Buffers lately. It's funny how the terminology you use reflects the work you've been doing.
     
  29. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @lazygunn: That asset is paid for, I was looking for a way to mod it myself.

    @tatoforever: I so hope you can find it... pweeease? :)
     
  30. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Hi guys, I figured it out:
    Basically, AutoLight.cginc has all the shadow mapping helpers tucked into a neat package. And once you know which part is the one you need to modify, doing the rest is a breeze! One thing suggested: put the AutoLight.cginc into a folder marked "Resources" then use a custom shader in the same folder: your new shadow mapping will come to life!

    You may also need to clone the other .cginc's depending on the shader... ;)*

    *EDIT: Forget the last line, all you need is the AutoLight placed with the shaders, then it will work wonders... :)
     
    Last edited: Jul 21, 2014
  31. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,501
    More interested in getting some optimisations in to be honest. Shadows are still expensive regardless of platform... more speed means more other fun things to draw.
     
  32. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,501
    Yeah what he said. More stuff/choices for usability rather than just throwing a quality filter on things or going to SM3.
     
  33. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @hippocoder: Mr Hippo, you have a point. It was definitely annyoing when I would make my shadow filter... only to have SM2.0 spit out complaints about register limits!
     
  34. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,344
    Old-ish thread, but... I thought the transporter demo :

    had pretty kick ass soft shadows (towards the end with the spinny rings). Which led me to believe we would see new shadowing for Unity 5. But I read here it's not the case. Then what is going on in the demo?
     
  35. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,501
    Uh those shadows are perfectly doable in current unity though, they're moving pretty fast. In any case being able to specify the shadow quality at a fine grain like superpig suggests would be awesome for speed on what is possibly one of the messiest hack fest parts of Unity. I've spent a long time going through it's shadow system and include files, and there's tonnes of speed to be had, just not easily as it could be.
     
  36. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    In a home project once I implemented VSM. I can't recall it being terribly complicated. And it was a deferred/forward renderer too. But I have no idea what Unity is doing on their backend. It was just a straight forward implementation based on Crytek's paper. Wasn't worried bout light bleeding or whatever it is called.

    Unity's current shadows look good too me tho. I'm not an artist by trade so I am not going to stare down and nit too hard though
     
  37. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,344
    They are? Unless the compression from the youtube video is doing wonders, I can't get shadows from point lights look that soft or that smooth. Or did you mean they are do-able by messing with AutoLight? Then, yeah I guess they are doable.

    So are those shadows in the video done with a custom AutoLight?
     
  38. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    Maybe those shadows were made with good old shadow cookies.
     
  39. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,344
    I don't believe cookies work on point lights though.
     
  40. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    They do, I use them too.

    http://docs.unity3d.com/Manual/class-Light.html

    They probably generated the texture by baking the shadows onto a cube and using this textures for the cookie. I could be wrong though.
     
  41. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    Yeah, I think in that demo there's just a cookie on a point light. And point lights with cookies have worked since Unity 1.0 or so.
     
  42. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,318
    But the ring rotation were random (it seems), so is it realtime updated point light cookie?
     
  43. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    652
    No the light would be parented to the same transform as the ring, so they just move together.
     
  44. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,318
    Ah, i see that make sense....
     
  45. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Wait, hang on, does that mean theoretically, us indies could write a tool that bakes point shadows into a POINT LIGHT COOKIE!? :eek:

    and such shadows could be any resolution we want, so that would work out really nice! :)
     
  46. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,925
    Cookies can never be used as proper shadows. Because the 'shadow' would be projected over everything. Meaning, if you had a pillar that casted a shadow over a floor, its own shadow would be projected over itself on the side facing the light.
     
  47. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    True... but don't you have a layer mask to take care of that? o_O
     
  48. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,318
    Well it's been done before, it's long time ago when unity were still around 2.xx Someone using the point light cookies for shadow and it works great, tricky but it works.
     
  49. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,528
    Yes, but like others said, this is a very crude approximation of "real shadows" - since it does not have any depth information. That said, "fake shadows via cookies" has been a very common trick in games since, well, forever.
     
  50. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    210
    What's the performance implications of light cookies?