Search Unity

Unity 5 dynamic and baked static shadows broken

Discussion in 'Global Illumination' started by DaddyMac, May 14, 2015.

  1. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    I think you would need Mixed mode in the light settings to work (which it doesn't) to get shadows. I think it sort of works for Directional Lights, but not others.
     
  2. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Thats pretty crazy, that basicly means the Engine is broken. We are targeting VR and you cant have real time shadows for the static enviroment. oh well, I hope they fix this soon. The lab renderer does not really work for us
     
  3. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    There must be some projected shadow systems in the asset store. I guess it's broken, but if it was an easy fix they would've done it by now.
     
    Last edited: Jun 16, 2016
  4. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
  5. Thomas-Mountainborn

    Thomas-Mountainborn

    Joined:
    Jun 11, 2015
    Posts:
    501
    Yes there are. Unreal does this for instance, and even the indie engine Phoenix (for Overgrowth) does so, as described here.
     
  6. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    5.4.0b24 still has this problem.
     
  7. GON2

    GON2

    Joined:
    May 16, 2013
    Posts:
    1
    5.4.0f1 RC1 still has this problem.
     
  8. niflying

    niflying

    Joined:
    Jul 11, 2012
    Posts:
    108
    5.4.0f1 RC1 still has this problem too
     
  9. artur-leao

    artur-leao

    Joined:
    Feb 3, 2015
    Posts:
    66
    5.4.0f2 still broken
     
  10. soufianetafersite

    soufianetafersite

    Joined:
    Jul 24, 2016
    Posts:
    9
    5.4.0f3 still broken
     
  11. Max_Bol

    Max_Bol

    Joined:
    May 12, 2014
    Posts:
    168
    Depends on the rendering method used.

    On Deferred Rendering, since the shadows are created per-pixel, adding lightmapped objects shadows onto dynamic objects requires an additional pass, but it can be done. In the case of the Standard Shader in Unity 5, the additional pass has already been added so it should appears.

    On Forward Rendering, since every object get its own lightmap and shadow map generated (either from the baked lightmaps or the real-time light rendering process), dynamic object is supposed to take the "real-time" version of the shadow from the lightmapped static object. Sure, it's not the same "quality" as the baked shadow and nobody is saying that a dynamic object is supposed to get the lightmapped shadows, but the dynamic object is supposed to be affected by the soft or hard shadow casted by the static object (the same kind of shadow as you get with dynamic's shadow over another dynamic shadow).

    I did some testing and...
    Currently with mixed lights :
    • When a dynamic (none-static) object cast a shadow (soft or hard) over a lightmapped (static) object, the shadow is registered, but at some point, it's overwritten by the lightmap pass instead of blended.
    • When a Lightmapped (static) object cast its real-time (soft or hard) shadow onto a dynamic (none-static) object, the shadow is registered, but automatically overwritten by what seems like the shadow from other dynamic object.

    In other words, right now, shadows from statics and non-static meshes aren't blended as they are supposed, but overwritten instead. One thing I noticed which gave me an hint is that during the baking of the lightmap, during a really short amount of time, both the first baked pass (which is raw and crudely dark) and the real-time shadows seems to be blended correctly, but as soon as the GI does its pass with the Ambient Occlusion, Indirect Lights, Bias, etc. which smooth the baked shadows, the real-time shadow are then "removed" (more like cut out from the rendering process)

    I have been inverse-engineering the standard shader for a while now and from what I have checked, the problem seems to be from around where the UnityGI data is being handled during the blending passes of the shaders (at least in forward rendering). It could be the UnityGI data itself or some kind of rendering error in the pipeline where it's handled... but as it's an huge hell to check and follow as note even 5% of Unity's standard shader's method is documented... It's literally like if you're opening a dozen of chests with tons of different coins and you're searching for coins with a specific size and year which is scribbed in really tiny character one one side of each coins.
     
    Last edited: Aug 4, 2016
  12. dillon_kneeland

    dillon_kneeland

    Joined:
    Apr 5, 2014
    Posts:
    1
    5.5.2f1 still broken
     
  13. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    They have a complete new lighting model in 5.6 addressing this. Can't wait to try it
     
    topherbwell likes this.
  14. kemalakay

    kemalakay

    Unity Technologies

    Joined:
    Jul 12, 2016
    Posts:
    224
    topherbwell likes this.
  15. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    I have spent the past two weeks trying unsuccessfully to get a dynamic object (player character) to cast shadows onto static objects (my terrain) unsuccessfully. How much of this has actually been fixed? I'd really like to know because as someone who has been using Unity for a few years I am downright frustrated by this.

    Another question; I see 5.6 on the downloads page, but I am currently on 5.5.2f1; when I go to Help> Check for updates Unity is telling me I am up to date. Which one is it? I'd like to update through the editor rather than manually updating and risking breaking things in my project, which has happened in the past.

    Any answers are appreciated; I love Unity and have been loyal for years but honestly if these lighting issues are not fixed and very soon I am switching engines.
     
  16. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Make sure you are not using Subtractive mode, it works like the old lighting prior to 5.6. Change to for example Distance shadowmask mode and make sure light is in mixed mode.
     
    topherbwell likes this.
  17. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    With the new lighting in 5.6, I was able to use one light in mixed mode to both bake static object shadows and also light the player/cast shadows in real time.

    One thing I still have not been able to figure out: what about trees that were painted on to a terrain using the terrain tool? Despite the prefab being static, none of my terrain generated trees are baking. What is happening instead is that the painted on trees are casting realtime shadows, which is specifically what I'm trying to avoid. I also noticed that the shadows from terrain trees are glitchy; they have little gaps in the shadows from geometry. This is something that is easy enough to fix with a few settings on the prefab, but the trees being generated by the terrain do not seem to be taking in these settings as the shadows on manually placed items look fine but on the terrain generated items they are glitched.
     
  18. K_Andrei

    K_Andrei

    Joined:
    Jan 19, 2014
    Posts:
    2
    How did you manage to achieve object to cast shadow from mixed light? For me it does not work at all.

    In the image below purple objects are static and grey objects are dynamic. Directional light mode is set to mix. Regardless of lighting mode dynamic objects DON'T cast shadow on other objects (both static and dynamic). baked light 56.png
     
  19. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    upload_2017-5-9_10-55-19.png
    I set my directional light to mixed, did not mark it static. My objects in scene are static, player is dynamic. I have not played with it much, but I seem to be getting the baked lighting on statics and realtime shadow from the dynamic object with the above settings; camera rendering path is set to forward.

    I don't know if this is the answer, so take it for what it is worth, but perhaps try the Shadowmask mode in mixed lighting.
     
  20. sonnyboy

    sonnyboy

    Joined:
    Oct 25, 2015
    Posts:
    10
    I want to ask again if anyone having problems with having dynamic lights on baked lights. I have a scene baked on 5.5 and it works well but a new scene no matter what I did is not working. I also used topherbell's setup aboe and used any kind of variation. Basicly, I setup bake objects as static and real time shadow objects as non static. Light is on mixed mode(tried all modes actually). Mixed lighting mode is shadowmask(also tried all modes). I have been using Unity 7+ years so I believe I haven't missed a simple thing on there. Is there anyone had the lightmap with dynamic shadows for non-static objects working?

    Thanks
     
  21. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    His screenshot shows Shadowmask mode, its not even available in 5.5, you need to migrate to 2017 to get Shadow-mask. If you move to 2017 and bake under Shadowmask you will get correct behaviour
     
  22. sonnyboy

    sonnyboy

    Joined:
    Oct 25, 2015
    Posts:
    10
    Sorry for mis-information, I wanted to say I had a working baked scene from 5.5 but I couldn't get it worked after 5.6 and later. I tried 5.6(two late versions), 2017, even 2018 beta. Those settings do not work anymore in my setup and I used all variations.

    Any idea what may go wrong?
     
  23. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Sometime the gicache gets corrupted for me, if i clear it it works
     
  24. _creatio_

    _creatio_

    Joined:
    Mar 21, 2013
    Posts:
    43
    Seems like, I'm having the same problem. The shadows work in the editor, but not on the game scene.

    So far, I've found that the cause of the problem is my multi-camera scene rendering. Dynamic objects, are getting rendered with a different camera, than the terrain. If only I setup culling masks to render the dynamic objects and the terrain with the same camera - everything works fine. But it's not an option for me (getting other artifacts)... :(