Search Unity

[SOLVED] Lightmapping not working with Lights

Discussion in 'General Graphics' started by dragriff, Feb 10, 2016.

  1. dragriff

    dragriff

    Joined:
    Oct 22, 2015
    Posts:
    39
    Hello. I have been looking around quite hard, watching Youtube videos and even trying to find the answer in Forums, but I just can't seem to find an answer to my issue.

    Basically, as far as I understand, by using Unity Lightmaps, you can have the objects look like they have lights shining on them, without actual lights being in the scene, correct?

    Well, when I try to bake my own lightmaps, stuff like meshes with Emission on them and such things seem to work fine, but whenever I try to add a Light into the scene (like, let's say, there's a lamp on a person's desk) it never works for me. Unity seems to bake something, but as soon as it's done, the scene becomes dark again, as if the Light wasn't there.

    Yes, I've set everything as Static, I've tried checking the "Preserve UVs", and yes, I tried setting the Lights as "Baked" or "Mixed". Nothing seems to work.

    Here are some screenshots of what I mean:

    I made a quick New Scene and put a bunch of meshes into a box form, to simulate a closed-off room and I put a single Point Light in it.

    This is how it looks when the light is set to "Realtime":



    And this is what happens when I bake the Lightmap:



    I have NO idea what I'm doing wrong, so if someone could help me out here, that would be great.
    Thank you.
     
    RickshawDerpyDerp likes this.
  2. PeteUnity3D

    PeteUnity3D

    Unity Technologies

    Joined:
    Jan 4, 2016
    Posts:
    68
    Sorry to ask something that you've already stated you've done but I can only go off the shots. Are you sure you have the lighting culling masks and baking type correct in your scene? Do you have this unity scene I can look over?
     
  3. dragriff

    dragriff

    Joined:
    Oct 22, 2015
    Posts:
    39
    Thank you for the response.

    I'm really new at this (which might be the problem to begin with), so I'm not entirely sure what Lighting Culling Masks are, OR how I would check baking type. Where would I check that?
    Also, if I were to share my scene, how would I go about doing it? By sharing the Project Folder?
     
    BrandyStarbrite likes this.
  4. PeteUnity3D

    PeteUnity3D

    Unity Technologies

    Joined:
    Jan 4, 2016
    Posts:
    68
    No Problem Dragriff.

    To create a small version of your project, duplicate it to somewhere and remove the Libary folder (leaving Assets and Project settings) along with any files in the assets folder you don't feel to be relevant. Zip up the project folder and then send it through to my inbox if you don't want to publically share it.

    This is a good resource to explain the different settings available in the light component: http://docs.unity3d.com/Manual/class-Light.html

    Lighting culling masks are a way to exclude some geometry from being affected by the light. based on what I can see happening in your first shot, I'd say this probably isn't your problem.

    Are you using normal primitive boxes included with Unity or is this some geometry you have created in a modelling package?
     
  5. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    It should be simple.
    • Set geometry/meshes to Static.
    • Set lights to Baked.
    • Make sure imported meshes have Generate Lightmap UV's checked.
    • Turn off Precomputed Realtime GI in the Lighting panel.
    • Bake.
     
  6. dragriff

    dragriff

    Joined:
    Oct 22, 2015
    Posts:
    39
    Okay, apparently the one thing that I was missing was to Turn off Precomputed Realtime GI.
    I did everything else BUT that, and as soon as I checked it, I can bake lightmaps from Lights now.

    There are other issues now, like strange artifacts on some parts of my meshes, but I guess that's a completely other issue now.
     
  7. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Try unchecking Compressed in the lighting window.
     
  8. BamBamAlicious

    BamBamAlicious

    Joined:
    Jan 29, 2017
    Posts:
    58
    So, just came across this myself and combined with the tips above, one last thing got my Lightmap working. I changed my shaders from Specular, to Diffuse... and lo and behold! My lightmap works!!
     
    Last edited: Mar 24, 2017
    KaletheQuick likes this.
  9. KaletheQuick

    KaletheQuick

    Joined:
    Feb 12, 2016
    Posts:
    41
    Same here.
     
    BamBamAlicious likes this.
  10. GameEverything

    GameEverything

    Joined:
    Feb 22, 2016
    Posts:
    10
    I'm glad I read that because I probably would've never figured it out. Greetings from 2018, lol.
     
    CGCowboy and BamBamAlicious like this.
  11. Ruuubick

    Ruuubick

    Joined:
    Apr 20, 2014
    Posts:
    17
    I am having the issue described by the OP, but none of the solutions provided fixed it for me, is there anything else in the settings that I could look at ? (I'm on 5.6.3p1)
     
  12. Evan_27

    Evan_27

    Joined:
    Jun 17, 2019
    Posts:
    1
    None of the methods worked above, but something else helped me. You can check to make sure that the light is the same z level as whatever platform/art you want it to shine on, since its 2D, it will not shine on anything but the z level the art/platform is on.
     
  13. aloften

    aloften

    Joined:
    Aug 25, 2017
    Posts:
    18
    Weird...I have been having this problem on and off while doing some optimization and I couldnt quite figure out what would cause it to break and what would fix it.

    While reading this forum, after playing two rounds of my game, I noticed the lights are back. ?!?!?!

    I think its because I cleared the baked lighting data. I think unless you have it auto generated, you have to clear it and rebake when you move lights or add more maybe? I mean it would make sense. I just dont think theres enough lighting direction in cliff-notes style for newbies.
     
    thenonrealist likes this.
  14. firestorm185

    firestorm185

    Joined:
    Sep 23, 2014
    Posts:
    24
    For anyone using that free Sci-fi Syled Modular Pack to build worlds off the Asset Store, make sure you go in and manually set each prefab's models to lightmap static. They aren't by default and it breaks baked lights.
     
  15. yakuphan

    yakuphan

    Joined:
    Sep 17, 2017
    Posts:
    3
    This may occur based on whether the game object which the light illuminates contributes to global illumination. You can fix this by clicking on the game object and checking Mesh Renderer > Lighting > Contribute Global Illumination checkbox is ticked/unticked on Inspector window.
     
    BrandyStarbrite likes this.
  16. unity_7C7E9D84B8AC4FA40DD3

    unity_7C7E9D84B8AC4FA40DD3

    Joined:
    Nov 20, 2022
    Posts:
    3
    I also have the same issue. Later I check the scene. If you want to bake the light then a minimum of 1 object should be (floor) static(Contribute GI) enabled.
     
    dmitryii2 and Pgames3D like this.