Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to have real time shadows in a scene with baked lighting?

Discussion in 'Global Illumination' started by Harrison_Hough, Mar 17, 2016.

  1. Harrison_Hough

    Harrison_Hough

    Joined:
    Dec 3, 2015
    Posts:
    43
    Hey I am wondering if its possible to have real time shadows showing on a scene where almost all of the objects are set to (lightmap static) and have the lighting baked into them.

    As I mentioned I have a bunch of lights in the seen with the "Baking" setting set to baked so all the walls floor and static objects have baked lightmaps. I have a character in the scene that is not static but I want the shadows to show on the floor and everything else.

    I have tried using Light probes which gets the light correctly but it does not apply any shadows to anything in the scene. I have tried both Forward and Deferred rendering paths but still nothing.

    I have also tried adding in realtime lights (as well as the already baked lights) to provide shadows coming from the Character. That works BUT it brightens up the rest of the scene so the lighting goes out of wack. I then tried to put it on a separate layer that only the character is on but then the Shadows don'nt show on anything.

    Surely there is a way to get realtime shadows on a baked scene?
    Any help would be awesome!
     
  2. Owers

    Owers

    Joined:
    Jul 7, 2012
    Posts:
    39
    AlexTinyRebel likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,021
    He's not asking for mixed lights exactly. He's asking for lights that only add a bit of realtime shadow to the character and do not contribute to light at all otherwise.

    It can be done with a bit of tinkering in Unity 4 for mobile. Not sure how/if it can be done in 5 without too much fuss.
     
  4. bart_the_13th

    bart_the_13th

    Joined:
    Jan 16, 2012
    Posts:
    485
    Maybe if you added the realtime light set in mixed mode before baking the scene will help...
     
  5. mattSydney

    mattSydney

    Joined:
    Nov 10, 2011
    Posts:
    171
    I was wondering this. So if you bake your static scene and want a few real time shadows, it cant be done? What is mixed lighting supposed to do? (it it worked?)
     
  6. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Eh? Its my understanding of mixed lights that it will do exactly as he wants. You would just delete the light probes. Set the lights to mixed which will bake for the static objects but light the dynamic objects as a realtime light including casting shadows on the baked stuff. Am I missing something here?
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,021
    He doesn't want to "light" the dynamic objects, he just wants shadows to be cast.
     
    afshin_a_1 likes this.
  8. bart_the_13th

    bart_the_13th

    Joined:
    Jan 16, 2012
    Posts:
    485
    A couple of options:
    A) setting the shadow-casting-realtime-light lightcolor to be very low(near black)
    B) setting the shadow-casting-realtime-light light strength to be very low(near 0)
    C) use "unlit" shader for other objects that supposedly not affected by light
     
  9. Harrison_Hough

    Harrison_Hough

    Joined:
    Dec 3, 2015
    Posts:
    43

    Yeah unfortunately I have tried the latest Beta Unity 5.4.b10 and the mixed mode still doesn't work. Tried it both with and without probes in there. Unless I am somehow I am doing it wrong.
     
  10. Harrison_Hough

    Harrison_Hough

    Joined:
    Dec 3, 2015
    Posts:
    43
    Yeah that's what I want, and what I assume would happen but it doesn't. In the editor it looks like it works initially as it shows shadows (for both dynamic and static) objects and lighting correctly initially. But once you bake it the dynamic shadows disappear forever!
     
  11. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Unfortunatly, mixed lights are broken at the moment. Check out the 100s of threads about it.... :(
     
  12. SuperUltraHyper

    SuperUltraHyper

    Joined:
    Sep 7, 2015
    Posts:
    112
    "at the moment." == over a year.
     
  13. Harrison_Hough

    Harrison_Hough

    Joined:
    Dec 3, 2015
    Posts:
    43
    Just an update, the latest Beta 5.4.0b13 has some of this fixed.
    Directional lights now work in mixed mode. So non static objects can cast realtime shadows on static objects whilst the static object can still have back shadows on it.

    However this doesn't work for spotlights or point lights (which doesn't help me much) but at least its a start.
     
  14. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    541
    Very interesting. I give b13 then a try. We're experiencing some major bugs currently with realtime shadows and static lightmaps. Not sure if they are related to mixed mode though.
     
  15. Hjeldnes

    Hjeldnes

    Joined:
    Jul 22, 2012
    Posts:
    116
    @Harrison_Hough Where do you see it was fixed? It does not work in the latest beta. I had a look. You get both a dynamic shadow, and a baked shadow from a mixed light, but they do not blend properly(which is sort of the point of the whole thing). The realtime shadow is too dark. You can kind of adjust it by reducing intensity of shadow, but it will not work when you have a normal variation of light and shadow.
    I'm sure unity would have a celebration and invite us all when mixed light mode is fixed! At least I hope they will tell us when they have something we can test :)
     
  16. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    541
    Can confirm that it's not working.
     
  17. Harrison_Hough

    Harrison_Hough

    Joined:
    Dec 3, 2015
    Posts:
    43
    Sorry I shouldn't have said "fixed" but I was able to use a realtime directional light (in addition to my baked spotlights) to get realtime shadows of the character into the scene with baked lighting. It is far from perfect however, the realtime shadows don't always show correctly from different camera angles (weird I know). Also another problem with this option is that the directional light does add light to the rest of the scene so I had to turn the intensity down a bit.
    But this seems to be the only way I could get the realtime shadows with the baked lighting setup.

    This is actually both in 5.4.0b13 and 5.3.3f1.

    And yes it doesn't blend properly but the shadows are there

    Anyways hopefully it gets fixed soon!
     
    ROBYER1 likes this.
  18. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    I'm having issues trying to do a similar thing I think.
    I have a realtime directional light (the sun) which moves throughout the duration of the level to create a day night cycle.
    However I'd like my streets to have street lamps that come on when it gets dark.
    I'm using 5.3.4 f1

    I thought I could do this at run time by switching in the nighttime baked lightmaps.
    However realtime shadows only cast on the terrain where the baked light is on the lightmap.

    With all realtime lights, this is the sort effect I want to achieve.

    Realtime Directional & Points:
    Screenshot 2016-04-13 14.14.43.png


    However if I change the point lights to baked and enabled baked GI
    Set my realtime sun light to mixed
    Point lights intensify, which i can work around but they work along with light probes for the dynamic characters.
    However, the realtime GI & sun light doesn't appear to affect the terrain, it's baked bright.

    Mixed Direction & Baked Points:
    Screenshot 2016-04-13 14.12.27.png
     
    Last edited: Apr 13, 2016
  19. rame16

    rame16

    Joined:
    Nov 21, 2012
    Posts:
    29
    Hi i'm interested also, coz it could be a fine setup