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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mixed Mode Fixes and Lighting window preview 2: Mix Harder.

Discussion in 'Graphics Experimental Previews' started by willgoldstone, Sep 9, 2016.

  1. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Hey @CreativeChris @Jesper-Mortensen @uy3d @fguinier @kemalakay @willgoldstone Thanks for your awesome work. I've just tested the build and it's really great. :)
    I have still two questions.
    • According to what you said, this will not be shipped in the 5.5 but maybe in the 5.6, could you give some estimation ? 2 monts ? 6 months ? 1 year ?
    • Is there a way to get static objects realtime shadows on dynamic objects and dynamic objects shadows on static objects ? It's the same as the Shadowmask mode but with the addition of static objects realtime shadows on dynamic objects.
     
  2. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    To Unity guys,
    Please take the time to read/answers users feedbacks. I'm pretty sure you guys are very busy and read them all but we got plenty of unanswered feedbacks in the previous page for almost two weeks now. :D
    Right so I tried for a couple of hours v2 of Mixed Mode build and i ran intro a small issue. It seems to bake indirect lighting no matter what. Here:




    I've tried both Distance Shadowmask and Shadowmask and it always bakes indirect, even when the indirect multiplier is set to 0. Also, the directional lightmapping bake is for indirect lightmaps right?
    What I want is real-time direct light and static + dynamic shadows only. At least have the option to not bake indirect lighting too.
    Also, the directional lightmapping bake is for indirect lightmaps right?
     
    Last edited: Nov 16, 2016
  3. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I've put out a small video with a test scene showcasing the blending of dynamic and static shadows:
     
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Man i've been asking this from the first mixed mode version, i do really hope that we can get this :(
     
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    This cannot be correctly achieved with baked raytraced shadows unless you want to project the shadows (without any depth comparison) onto geometry, this can lead to unwanted results such as backface projection or mid-air projection. Think of it as the way projectors work, it will do the same.
    There's an other way which involves two depth texture per-light, first one bake depth buffer for every static object on it's frustum only once (at scene load or in-editor) and a second depth texture updates real-time (when there's a dynamic object moving on it's frustum). You end up with two depth textures, one static and one dynamic. Last part of this technique involves decoding both depths (compare against dynamic geometry), combine them and multiply the resulting combination by your final lighting contribution of your dynamic geometry. You trade less drawcalls for more memory bandwidth and shader instructions.
    A simple trick that adds extra drawcalls is to add geometry that wont be seen by your main camera and cast dynamic shadows onto the scene. Or simply to duplicate the static geometry you want to cast shadows on your characters and then set it's cast property to "Shadows Only".
    I think the simplest thing will be that Unity allow us to set static geometry to cast dynamic shadows too. Sounds awkward but let me explains (this is what I do on my custom renderer). I for instance bake the whole static objects, then select the static meshes on the scene that will potentially cast shadows onto my dynamic characters and let them get rendered on the dynamic shadows (they will contribute to dynamic shadows too). But with Unity renderer, once an object is baked with lightmaps, it won't cast dynamic shadows anymore. Even if you set it back to dynamic (non-static).
    If Unity don't plan to add any way to cast static shadowsmaps onto dynamic objects then at least add a shadow casting mode that will let us both bake static lighting/shadows and cast dynamic shadows too. If any Unity folk want to get some feedback about this, please reach me out.
     
  6. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    This is a workaround but the shadows overlaps with the lightmaps baked shadow so I am not very seduces by this solution. To avoid this, I can play with layers but again this is more of a workaround than a correct solution.

    I totally agree and that's what I was asking for. but the static geometry should only casts dynamic shadows on dynamic geomtry to not overlap baked shadows.

    And I would like to know if this thing is possible and planned. :) As you said @tatoforever a feedback about this could be very useful and interesting, maybe some of them could help us : @CreativeChris @Jesper-Mortensen @uy3d @fguinier @kemalakay @willgoldstone
     
  7. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @MaT227,
    Yes, using the trick I've explained both dynamic and static shadows casted by the static object will get blended on static geometry. Dynamic objects will only receive the dynamic shadows from the static object normally.
    I've already shipped a game with this technique and it does the job well (it's better than light probes approximate shadows). Although, the best still the first idea I've proposed.
     
    Last edited: Nov 16, 2016
  8. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    457
    It will depend on the quality, we cannot commit to a version but the team are working hard to get it in as quickly as possible.

    For bullet point two, I poked the team to answer.

    Thanks, Chris
     
  9. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thanks for the answer @CreativeChris, I am impatient to see the team answer. :)
     
  10. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    @MaT227 Have you tried the distance shadowmask mode? Within the shadow distance all statics and dynamics are rendered into a shadowmap, so they cast shadows on each other. Beyond the shadow distance dynamics won't cast any shadows anymore, but can still receive shadows from statics via light probes. Statics will use the shadows stored in the shadowmask so you will still get nice shadows in the distance.
     
  11. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I think he's asking about proper shadows on dynamic objects from static objects between shadow distance, not beyond.
    Why you guys can't sample static shadows on dynamic objects? The dynamic object is doing self-shadowing anyway. You just need to bake a static depth buffer and sample it on dynamic objects. You can even do this from the light itself, no need to bake the whole scene. As simple as that. :)
     
    Last edited: Nov 16, 2016
  12. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    @taoforever I
    So yes that's the current behavior, we always bake a lightmap when baking ShadowMask. But indeed you have a really good point if you don't want any fully baked light nor baked indirect lighting in the scene you don't need lightmap at all. Thanks -> added to the backlog ! Meantime i haven't tryed but i suppose that some black magic in the shaders to only fetch ShadowMask but not the Lightmap + some scripting to only grab the ShadowMask from the lightmapData could be a workaround.
    "directional lightmapping bake" is for lightmaps in general as they contain both indirect lighting from the "static" light and full lighting from the "fully baked" light.

    Thanks again for the feedback!
     
    JamesArndt likes this.
  13. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    So the idea of the shadowMask mode is to only render dynamic objects only as shadow caster (so we have very few of them). We can't sample the ShadowMask for dynamic object because the ShadowMask is defined in UV space (same as lightmap) of the static objects so there is no direct relation to dynamic objects. Thus the usage of occlusion probes for shadowing of dynamic object from static object in that mode. As you say this case seems to be more a case of "static shadow maps" ie a realtime shadowmap (thus in light space as usual) for static object, updated very sparsely/neither + another one for dynamic object updated every frame and then we combine them before actually using them -> this is on the roadmap but not part of this feature :)

    Make sense?
     
  14. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Hi,
    I didn't mean the static shadows baked with lightmapper (those cannot be sampled on dynamic objects yeah). What i meant is something similar to what you've describe in your last message.
    [EDIT] A possible optimization that could be done is to update the dynamic depth buffer only if there's something moving on it.
    Also, to properly combine both the static buffer and dynamic buffer, you cannot multiply both shadows after decoded. Instead, sample both depths, compare distances, discard the one that is far from light pos and then compare that distance against scene geometry.
    This will solve shadowing from static geometry onto dynamic geometry. Dynamic geometry shadowing static geometry is already solved but you can use this technique on static geometry too (if no Shadowmasks is baked). ;)
     
    Last edited: Nov 17, 2016
  15. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    Yeap! definitively :)
    Yeap! Another option is to "merge" the two shadow map to only one map, you pay the bandwitch but after that its a traditional shadowmap sampling (1 fetch rather than two) so maybe cheaper for large kernel :)

    Summing up ! yes we want that, but not part of that feature/build thus :)
     
    tatoforever likes this.
  16. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    @fguinir,
    Definitely, the idea of one atlas for all static depth and dynamic shadows (updating static once and dynamic if/on objects moves on lights frustum) and reusing it will add tons of optimizations. Not just on static lights, fully dynamic lights, quite often people never move those lights at all, the optimization static/dynamic depth buffer trick can be used there too. And most important, will work on any scene type with all objects types. :)
    Regards,
     
    fguinier likes this.
  17. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Will there be any more releases of this or are the second one the final one?
    Edit: How do i set things up to have static bakes interiors, but still have realtime objects inside that does not receive shadows from the "sun"?
     
    Last edited: Dec 1, 2016
    StaffanEk likes this.
  18. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Will this get integrated into 5.6 beta?
     
  19. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    245
    I'd really like to get an answer to this. Both the Progressive Lightmapper and the Mixed Mode lighting are *SERIOUS* improvements to Unity, and I've had to park a couple of game projects, as they need these features before I can ship 'em. Pretty please.
     
    JamesArndt and StaffanEk like this.
  20. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Why is "Fully Baked" an option for mixed mode when it's exactly the same as "Fully Baked" lights? It suggests that they must be different.
     
  21. WermHat

    WermHat

    Joined:
    Jul 13, 2012
    Posts:
    88
    Hi all, apologies if this is the wrong place to ask... we keep hoping that the new system will support cookie baking like Unity 4 used to. The current preview still does not. Is this on the roadmap?
     
    StaffanEk likes this.
  22. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I seem to remember that Unity wants archviz devs to use the Unreal engine to bake ies and cookie lightmaps. That is at least the only sensible deduction I can make based on their development history. I mean Uniy lights don't even follow quadratic falloff for some inexplicable reason. They instead use some otherworldly clamping Jerry-rig.

    It's strange when you think about, it since Archviz is cheaper to do in Unreal because of the way Unity license fees are setup. You would think they would cater to this group since they obviously pay for even the splashscreen removal alone.
     
    WermHat likes this.
  23. WermHat

    WermHat

    Joined:
    Jul 13, 2012
    Posts:
    88
    We're a game studio, and we still can't jump to Unity 5 because we rely extensively on light cookies for interesting, textured lighting. This is on mobile, so there is no headroom for realtime lights.
     
    Last edited: Dec 6, 2016
    StaffanEk likes this.
  24. GenaSG

    GenaSG

    Joined:
    Apr 19, 2014
    Posts:
    111
    Hello everyone,
    I have a question regarding shadow mask. Excuse me if I'm missing something. Does shadow mask approach is the same as baked shadow map approach like this
    ?
     
  25. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    Just to give everyone a heads-up, as you can see at the bottom of this page the lighting modes will be part of 5.6 beta 2. That is the NEXT beta coming out.
     
    Adam-Bailey, ArthurT, MaT227 and 2 others like this.
  26. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Nice !
     
  27. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    In the blog post, I've read about a new option to specify realtime shadow fade out behavior. I guess this is related to shadows only.

    Currently, I am fighting the issue that realtime point lights create very hard edges in dark areas while using linear color space and mostly baked lightmaps (also see this thread). This is a considerable drawback for the kind of game I am working on.

    Considering all the upcoming improvements on the mixed mode lighting, do you think there would be a chance to add an option to specify the light falloff behavior for realtime point lights in order to also support more smooth edges in linear color space? I think this would be a quite essential improvement and beneficial feature for a lot of games.
     
    Last edited: Dec 19, 2016
  28. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
  29. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    Correct Inv squared attenuation is something we want to do very badly ! Yes. However no ETA yet. Meantime you can take a look at : http://answers.unity3d.com/questions/736758/easiest-way-to-change-point-light-attenuation.html
     
    moco2k likes this.
  30. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    The only problem with that method currently, the custom light atten are work realtime. But reflection and baked light still using the old light atten, any tips on that? or how to make work on reflection and baked lightmap?
     
  31. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
  32. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    You are right, we indeed need to handle correct light attenuation both at runtime and bake time engine wise and the workaround is only for the realtime (shader) aspect of lights.
     
  33. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    So is there any way to handle that? or nothing at all at the moment?
     
  34. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
  35. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
  36. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
  37. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    How about realtime spotlight on mobile? surely the newer devices could handle that right?
     
  38. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    397
    Just checked out a simple Unity game on Play Market and it uses realtime and baked shadowmaps. The thing is that realtime shadows blend well with the static ones, but static shadowmaps also cast themselves on dynamic objects! As far as I know you can't do this unless you are using light probes, but still they can't provide the results as here on a screenshot. UE4 also can do this and it looks incredible! I find this feature to cast static shadowmaps on dynamic objects without light probes to be very useful. What do you think about it?
     

    Attached Files:

  39. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    Hi Kolyasisan,

    You can already achieve a similar effect in Unity :) Light Proxy Volume are supporting baked shadows along with light-modes. This allow a dynamic object to enter a shadowed zone using a shadow gradient (On top of allowing it to receive better indirect lighting as usual).

    However and moving forward we also want to provide more control over the frequency of update of shadowmaps and allows static shadow casters to be renderer to the dynamic shadowmap only when the light move or rotate. The latter is in the roadmap and would be another way to achieve the effect you are looking for.

    Thanks for feedback!

    Florent
     
    Last edited: Apr 5, 2017
  40. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    397
    Hello. Very glad that you have such feature on a roadmap! Thank you for your reply!
     
    Last edited: May 31, 2017
  41. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
    @Joachim_Ante @fguinier @CreativeChris @uy3d @willgoldstone

    How do we get specularity back with new lighting mode and no realtime lights?
    For our project real-time lights are still not an option (sadly)

    Thank you

    You guys deprecated directional-specularity maps, because it was hard to support...
    After Beast was gone for almost two years we have spent countless weeks re-baking lighting again and again and again to achieve desired look and to fight bugs and lighting artefacts. Not even going to mention light probes (which took more than 2 years to fix)
    Now when we were happy with lighting ... Unity team decides to "deprecate" all that away =)
     
  42. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    231
    Directional specular lightmaps only worked for a very narrow set of use-cases, so we decided to drop this going forward.

    In order to use specular you should use a combination of:
    I'm guessing that SSR is outside of your budget so some carefully placed reflection probes combined with realtime lights using shadowmasks could be an option in your case? This way you won't be paying the cost of rendering shadowmaps, which is usually the showstopper for realtime lighting.

    What is your target platform?
     
    buttmatrix likes this.
  43. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
    @Jesper-Mortensen thank you for the suggestion. I'll take a look at shadowmasks performance on device.
    Our target platforms are iOS and Android
     
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    I'm trying to use the new lightmapping options in 5.6 for the first time, but I can't get any tree shadows to be baked with the Shadowmask modes. See screenshot -- the trees cast shadows only to the shadow limit in quality settings, but the cube has a baked shadow behind that. Trees and the terrain are all set to static, as is the Directional Light (which is set to Mixed mode). Hopefully I'm doing something wrong, but I can't figure out what! Anyone got a tip?
    shadowmask.jpg
     
  45. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    terrain tree shadow are implemented in 2017.2 beta
    GI: Terrain trees can now cast shadows into the baked lightmap for terrains. Terrain tree probes are now in the top of the tree canopy to make sure probes don't end up inside the tree trunk.
     
  46. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Oh, wow. Does the 5.6 and 2017.1 documentation mention that? I sure didn't see any note of it. Feels like Unity 2.0 all over again! :/
     
  47. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    i don't think they mention that as far as i remember. Yeah i agree about your last sentences, it happened since unity losing beast.
     
  48. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    So is there any lightmapping mode in 5.6.2 which bakes tree shadows onto the terrain? I sure can't find one....but I find it hard to believe that that would be true....