Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Distance shadows with Enlighten.

Discussion in 'Unity 5 Pre-order Beta' started by thehosse, Nov 5, 2014.

  1. thehosse

    thehosse

    Joined:
    Nov 29, 2013
    Posts:
    35
    Having some issues with shadows in the distance. I have a large sunlit scene that requires shadows in the distance, I can't set the realtime shadow distance too far as it hurts performance and reduces shadow resolution and I can't do a duel lightmap bake with Enlighten, so whats the solution for distance shadows in large sunlit scenes?

    In Unity 4 I would normally use duel lightmap mode to tween between far baked shadows and near realtime shadows. Whats Enlighten's thinking for this?
     
  2. Kubold

    Kubold

    Joined:
    May 10, 2012
    Posts:
    359
    Ha, I missed your post and submitted the same problem just a second ago. So... is dual lightmaps not implemented yet, or is it a bug and it should work, but it doesn't? Or maybe this new realtime shadows are so awesome that you can cast them to infinite distance without performance hit (I didn't try that actually)?
     
  3. thehosse

    thehosse

    Joined:
    Nov 29, 2013
    Posts:
    35
    Yeah tried setting shadow distance really far, as expected the shadow resolution drops the further you set it.

    Also tried baking the lights, can't see a way to make them tween between the direct realtime light. There doesn't seem to be any AO in the baked maps either. All these features I watched in the Unite videos just are not here...

    Really wish one of the Unity guys would chime in and lend some advice!
     
  4. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Personally I've found that with 4 shadow cascades you can get away with setting the shadow distance high enough to not need duel lightmaps (then again, I don't have massive scenes with distant mountains etc).

    Also, the AO on the baked lightmaps works fine.
     
  5. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Actually, it looks like your best bet is to set the shadow distance high, and then play with the cascade distances. That is, make a cascade or two very close to the camera, and then later cascades significantly farther out. That's how GTA5 does it, if you look you'll notice that nearby shadows are very crisp, and then at a distance become very blurry/pixelated.
     
  6. thehosse

    thehosse

    Joined:
    Nov 29, 2013
    Posts:
    35
    Yes the AO works fine baked onto a lightmap. Still a bit confused to what Enlighten does with the GI though, everytime I exit my scene and go back to it, my GI calculation and lightmaps are gone. Why is this not saving my lighting?
     
    Last edited: Nov 6, 2014
  7. Marc-Saubion

    Marc-Saubion

    Joined:
    Jul 6, 2011
    Posts:
    655
    I guess one way to get around this problem would be to use the LOD system, making your last level models a non shadow caster as long as the object isn't big like a building, this should preserve draw calls.
     
  8. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    I am assuming primarily out door:

    1. For high-end PC & next-gen consoles (Use deferred or forward rendering depending on if you have tons of realtime lights or not):
    A long shadow distance with shadow cascades and the new 5x5 pcf soft shadows is the way to go. Some games might also use fog to hide a shorter shadow distance.

    Use realtime GI & occluded skylight realtime gi to give some nice looking basic skylighting and do local lights with dynamic emissive objects as local light sources.

    The great thing about this is that everything is 100% realtime. You can change all lighting / emissive surfaces etc. Very nice looking time of day effect this way.


    2. For low-end PC & Mobile (Use forward renderer):
    Either use mixed mode on the directional light and short shadow distance.
    (Thus you get shadows from dynamic objects onto static objects with shadow mixing)
    Or use a project shadow to cast shadows from characters on the ground.

    Lightprobes captured the shadows from the static geometry thus when a character walks into shadow he will gradually become darker (No actual shadow cutting through the character though, for that you need the 1.)

    3. Very low end (low end mobile) (Use forward renderer)
    No directional lightmaps, just simple lightmaps + lightprobes. Maybe use a blob shadow for just one or two important characters to cast a shadow onto the ground.

    For this to work well you need:
    * Directional lightmaps working well (Current beta it does not but it should be available soon-ish in beta 13 or 14) Directional lightmaps work well and now even generate specular highlights, so it looks very close to a real light with full brdf.
    * New 5x5 pcf soft shadows. They are getting there, we still have some work to do on blending between cascades. But that should hit soon as well.
    * A bug fix for light mixed mode, which prevents the mixing to work like it did in 4.x on the standard shader. We'll have that working soon.


    In the future, post 5.0:
    * we want to add support for baked shadow masks
    * we want to investigate rendering the last shadow cascade at lower frequencies etc.
     
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    In iterative mode, we use a cache and if anything in the scene changes it will automatically recompute.
    For larger scenes, we recommend that you stick with the traditional "On demand" bake button style approach. You can also turn on iterative mode while you are specifically tweaking the lighting for fast feedback and then when you have tweaked all things right you can bake.

    Please note that precompute (the step necessary to use realtime GI) is part of what we call "bake".
     
    shkar-noori likes this.
  10. Sir-Spunky

    Sir-Spunky

    Joined:
    Apr 7, 2013
    Posts:
    132
    Have you considered some kind of realtime dual shadow maps, that blend between one close-up shadow map with low shadow distance and one far distance shadow map with a very high distance? It would almost work like a kind of progressive shadow resolution, that lowers shadow resolution in the distance and increases it closer to the camera.

    I have no idea if this can be implemented or not, but in theory it sounds like a logical solution that wouldn't be too hard on performance (although I might be completely wrong). It sounds like if this was balanced well, a large outdoor scene might get a better result with two medium resolution shadow maps using this approach compared to one very high resolution map with very high distance using just one shadow map, because you'd have better details up close.
     
  11. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    You've just described a dumbed down version of cascaded shadow maps, and Unity has supported it for years for up to four shadow cascades. In Unity 5 it looks like you also get total control over the distances of each cascade.
     
  12. Sir-Spunky

    Sir-Spunky

    Joined:
    Apr 7, 2013
    Posts:
    132
    Ahh, I suspected I was missing something :) Thanks for clearing that up! I'm definitely looking forward to be able to tweak the distances of each cascade, as that's the shadow setting I've been missing. That means I should also be able to accomplish better close-up shadows even at shadow distances of many thousands.
     
  13. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    If you've played GTA 5 (at least on Xbox 360) you'll notice that they manipulate the shadow cascades in just the way you're describing. The nearby shadows are very crisp, but after a few meters switch to very low res and blurry.
     
  14. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    In Forward Rendering Mixed Mode doesn't render realtime shadows in B13, is it supposed too and this is a bug, or is it a pending feature?
     
  15. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    This is a bug. We are aware of this and thank you for bringing it up again.
     
    David-Lindsay and Jonny-Roy like this.
  16. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    In some cases, realtime shadows work with Mixed lights and Forward rendering, if Lighting/General GI/Directional Mode is not Directional Specular (beta 13).
     
  17. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    It only works for me on objects that are non-static. Not sure if you are seeing something different, but I don't get dual shadows from static objects like with Deferred. (Although oddly it works in Deferred if you use the Forward rendering pipeline)
     
    chrismarch likes this.
  18. kurzemnieks

    kurzemnieks

    Joined:
    Nov 22, 2012
    Posts:
    16
    in b14 real time shadows on static objects work only in Non Directional and Directional modes. When in Directional Specular - they do not.
    Please say that this is work in progress and will be added?! :rolleyes:
    .. also light probes seems to have no effect on non-static objects ?!
     
  19. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    @kurzemnieks All those things work fine for me in Directional Specular mode. Have you checked if your camera is set to Deferred Legacy or proper new deferred?
     
  20. kurzemnieks

    kurzemnieks

    Joined:
    Nov 22, 2012
    Posts:
    16
    I was using Forward rendering. When using Deferred (the new one), then I get real time shadows on non-static object from static objects, but not the other way. If forward rendering there are real time shadows only between non-static objects.
    Anyway - I made super simple test scene with two static objects (blue) and one non-static (red). Standard shader on all. I attached picture with 4 cases - both forward rendering and deferred.
    As you can see - first one is the correct one with all real time shadows where every object drops shadow on all other. In all other cases something is missing. In deferred mode - all LM modes look the same.
    Test was done on geforce GTX 780, Unity 5 b14

    ps - is the Deferred now the preferred mode over forward? What is the solution for anti-aliasing?
     

    Attached Files:

  21. thehosse

    thehosse

    Joined:
    Nov 29, 2013
    Posts:
    35
    So is the general consensus for a large outdoor sunny scene is baked GI with realtime directional light?

    I ask as with the current toolset there is no way to blend dynamic object shadows with baked shadows?
     
    Last edited: Jan 19, 2015