Search Unity

Baked lighting on and off

Discussion in 'General Graphics' started by javsezlol, Jan 19, 2020.

  1. javsezlol

    javsezlol

    Joined:
    Dec 4, 2019
    Posts:
    6
    Hi I have a question about baked lighting.. If I have a scene with some static objects and 3 lights and it's all baked. Can I turn light number one off and will that turn that lights map off? Sorry for wording this badly
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    No. If a light is set to “Baked” then it cannot be modified in real time. Enabling & disabling the light will have no affect on the lighting of static objects in the scene. Understand the scene has one* light map which is a texture that has all lighting baked into it. It’s not one light map per light.
    * A complex scene or one with very high density light map settings may actually have multiple light maps if not all surfaces can fit into a single light map texture atlas.

    If you set the light to “Mixed” then you can modify the light in various ways, depending on how you’ve set the Mixed Lighting > Lighting Mode.
    https://docs.unity3d.com/Manual/LightMode-Mixed.html

    However, turning off a light won’t remove the indirect lighting from that light. For that you’d need to use Enlighten & Real-time Global Illumination, but that only works with real time lights, not baked lights.

    The way I’ve seen this solved by others is to actually bake out multiple versions of the light map data depending on the lighting setup wanted and swap between them at runtime. This requires some custom build scripts to accomplish and isn’t something neatly built into Unity. Alternatively I’ve seen people completely skip using Unity’s baked lighting systems and bake them out using external applications so the light maps are just texture assets.
     
    javsezlol likes this.
  3. TheWillCrow

    TheWillCrow

    Joined:
    Sep 14, 2019
    Posts:
    6

    Quick question. if i bake lights can i then later delete the light game object and still have the lighting effect on the baked area of item the light was shining on? i'm just trying to see in what areas I can optimize some performance down the road.
     
  4. gnovos

    gnovos

    Joined:
    Apr 29, 2020
    Posts:
    33
    Yes, after you bake the light it will remain in the lightmap until you run the light mapper again. Just try it out in a sample scene with a single light which will bake in seconds, then remove the light and you'll see the color stays. But this is kind of pointless because then you can never rebake the light map or you'll lose the light.