Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Lightmap baked even if lights are set to realtime?

Discussion in 'Global Illumination' started by Findus, Apr 19, 2015.

  1. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    What exactly is "realtime" when I set a light to realtime?
    I'd assume that all aspects of that light should be rendered in realtime but maybe that's a misconception on my part.

    It seems like the shadows and GI are baked all the time.

    In my example there is one directional light set to realtime.
    Only baked GI is activated. (Of course I could turn that off, as well, but that's not the point.)

    Apparently GI is baked.
    When I reopen the scene I see what I would expect to see, the realtime light not contributing to shadows or GI.
    (Image with the dark shadows ) If I trigger a bake, GI is calculated again.

    So I assume that "realtime" only refers to the shadow and if I want a light to not contribute to GI I put its bounce intensity to zero.

    (On a related sidenote I'd also say it's not really practical that baked indirect resolution is linked to realtime GI resolution if both are active. It might be the same thing under the hood, but it takes away control from the user. Maybe a checkbox to link/unlink them? )

    Anyway, shadows seem to be baked as well if the light is set to realtime! If I turn off continuous baking and rotate the light, there are visible double-shadows.
    Is this a bug or are direct (unbounced) light shadows no longer separate things like they used to be?
    (But why would GI then ignore the shadows? )
    Also having the shadows clearly separate should be a lot more practical when it comes to mixing realtime and baked shadows. Like the old dual lightmaps. Right now the mixed mode doesn't work yet, if I understand correctly. (And ideally it should ultimately work for any light, of course. )

    I'm using Unity 5.0.1f1
    The red objects are static, the white cube is dynamic and is using lightprobes.



    Directional_set_to-realtime.jpg Directional_set_to-realtime_after_fileopen.jpg Directional_set_to-realtime_light_rotated.jpg
     
    Last edited: Apr 19, 2015
  2. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    Well, it seems like turning the realtime GI off really confuses the whole system and is the main culprit, here.
    It seems like the baked lightmap will be applied two times or with wrong intensity.

    (Using deferred and linear, btw. )
     
    Last edited: Apr 19, 2015
  3. drolak

    drolak

    Joined:
    Jan 21, 2014
    Posts:
    49
    Same here - basically I see no difference between the Realtime and Mixed light setting.
    Even the culling masks won't help to exclude the light from baking.

    Bug?
     
  4. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,452
    I don't see any difference either. If I set the baking to mixed, I never see any realtime shadows from non-static objects, another bug I guess. In fact, when I set it to mixed, I'm still seeing a huge drop in framerate on my Android device, yet no shadows appear anywhere.
     
  5. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    Yeah, right now mixed is definitely not working as it ideally should. You should see shadows from realtime objects on realtime objects, though.

    The bug above is different from that in that the case of deactivating real time GI seems not properly to be accounted for.
    Realtime lights will be baked then into the baked map PLUS applied at realtime.
    You can see that in the above screenshots with the double shadow or just check the maps.
     
  6. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    Submitted a bug report. Case 697565

    The "report a bug window" takes ages to open, btw, on my system at least. Id guess around ten minutes, here.
    It looks like nothing is happening at all when pressing the "report a bug" button. (The process is launched, but you normally wouldn't notice that. ) I'd guess something like that could keep a lot of people from reporting bugs, because they simply move on when nothing happens. I know I did.

    I remember having this on Unity 4 too, with a different system and even more excessive times. Might be related to project size. If that's the case scanning the whole project in advance, without feedback for the user and the ability to cancel that process is probably not a good idea. Could be something else entirely, too, of course. Like searching for some path or internet adress.
     
    Meltdown likes this.
  7. j-baeza

    j-baeza

    Joined:
    May 14, 2015
    Posts:
    26
    I think your problem is due to the continous baking being uncheked... If you bake your scene, then untick continous and then move the sun, it's normal that your shadows double... Try to hit continuous bake or click build to update your shadows. Also, your scene viewport has light being unchecked... That's why the scene view only shows realtime shadows.
     
  8. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    Hi, j.baeza: Since the sun is realtime, it shouldn't be baked into the lightmaps. So moving the sun should not double the shadows. (Looking at the lightmaps itself also show that the realtime sun has been baked.)

    The scene viewport is irrelevant, here. I probably should have changed my layout for the screenshot, so sorry for that.

    Since the findings above are a bit dated and convoluted here's the exact repro case:

    Set up a simple scene
    E.g. Box on a plane, both set to static, with a directional light that casts shadows.
    Set the light to realtime. Turn off Realtime GI.
    Bake the scene.
    As soon as the light adds only in the slightest way to bounce intensity, it will be added to the lightmap (direct light, too) just like it was set to baked. It will continue to light the objects in realtime as well.
     
  9. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,452
    Where in those images the OP has posted does it show a 'light being unchecked' ? Can you elaborate on this.
    Thanks
     
  10. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    I think he's referring to the little sun symbol over the sceneview. I use sceneview just for navigation and editing, though.
     
  11. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    Good catch, forwarded this to devs.
     
  12. RagtagChris

    RagtagChris

    Joined:
    Feb 24, 2014
    Posts:
    6
    Is there any updated info on this? I just came across this issue too. I'm surprised that 6 months later this still isn't addressed. How are people working around this? I'll have to set up scripts that turn the lights on when the game runs, so they aren't calculated during the lightmapping process. A bit of a pain.
     
  13. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,452
    Use two lights in your scene, one for baking, one for realtime.
    Set the culling mask on each light to light only baked or realtime objects as desired.
     
  14. drolak

    drolak

    Joined:
    Jan 21, 2014
    Posts:
    49
    Culling masks work for you?
    I tried it and the realtime light is baked despite having properly set culling masks.
    Only disabling the realitme light before bake works for me.
     
  15. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,452
    If you set a light to realtime, it definately shouldn't be included in any sort of baking.

    In my racing game, I set my realtime light's culling mask to my Vehicles layer only, so only my monster trucks get lit by the realtime light. The culling mask on the baked light is set to everything else, i.e the Environment layer etc.
     
  16. drolak

    drolak

    Joined:
    Jan 21, 2014
    Posts:
    49
    Odd..
    In my case the realtime light adds to the lightmap even if I set the culling mask to nothing.

    But this workaround wouldn't work for me anyway. Dynamic objects wouldn't be able to cast shadows on lightmapped surfaces (the realtime light, which casts shadows won't cast it on surfaces that are not in it's culling mask), which is something that our game does (and I guess a couple of others too :)).
     
  17. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,452
    I use shadow projectors for my trucks shadows, yes realtime shadows won't work on your baked surfaces (which is where we need mixed mode)

    As to the realtime lighting being baked, you can also try clearing your cache in Preferences -> GI Cache -> Clean Cache. I find this clears up any funnies.

    But sometimes even deleting the Library and Obj folders is neccessary to completely remove any lingering lightmap info.
     
  18. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Any updates on this? I'm on 5.2.1p2 and lights set to realtime are still baked into the lightmap if Realtime GI is turned off. They also, (correctly, as they are not set to bake only) continue to apply light to the baked surface, effectively doubling the amount of light the surface receives.

    I see the bug (697565) isn't prioritized for any release, and that a workaround is possible. What is this workaround? Using culling masks does not work. Even a light set to "realtime" with culling mask set to "nothing" will be baked into the lightmap.

    This is kind of a showstopper for baking scenes without Realtime GI, it surprises me that it hasn't gotten a higher priority.
     
    _Radagan and drolak like this.
  19. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,199
    697565 should be fixed in 5.3
     
    NGC6543 and Futurerobot like this.
  20. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    That's good news! Any idea about the culling masks? I guess it might be complicated if the Enlighten package does not support that kind of data.
     
  21. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,199
    Culling masks were never supported for baked lighting so that is a completely new feature. It is on our todo list but no ETA yet.
     
  22. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    Same issue here... I think I have to disable the realtime lights before baking the lightmap. I'm looking forward the Unity5.3 release soon!
     
  23. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    Unfortunately changes won't be available in 5.3, but in 5.4, because Enlighten 3.03 didn't make it into 5.3.
     
  24. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,452
    Glad to see you guys are tightening up on your releases, and only releasing stuff when its ready.
     
  25. ruj

    ruj

    Joined:
    Feb 28, 2013
    Posts:
    113
    Wow, this is quite disappointing, it effectively makes an entire render path unusable without jumping through crazy hoops. Not even talking about mixed mode having no purpose right now (kind of wonder why it is even an option when it is completely broken). But having a bake path ignore the "realtime" setting on a light is just crazy to me.
     
  26. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    WOW, I just upgraded to Unity 5.3 and it won't open a scene if the scene has a previously baked lightmap data(from Unity5.2.2p4) in it.

    when I first opened the project in unity 5.3 it gives me a warning like this :

    Lightmap snapshot 'LightmapSnapshot' is inconsistent - 18 files out of 72 are missing. Realtime GI will be disabled. Please rebuild lighting for this scene.
    UnityEditorInternal.InternalEditorUtility:GetGameObjectInstanceIDFromComponent(Int32)
    UnityEditor.DockArea:OnGUI()

    I know from upgrade guide that lightmap data should be rebaked and I thought the warning could be the one.
    But Unity just stops responding when double-clicking the scene file.
    I terminated the Unity, deleted the lightmap folder, restart the program and re-opened the scene.
    Now it is 'opened'(scene objects are visible in both scene window and hierarchy window) but then it stopped responding again. I can't do anything to fix the problem. Scenes without a lightmap has no problem opening it.

    I'm downgrading to 5.2.2p4 now, but the download speed is way too slow!!!!

    -------------
    After downgrading to 5.2.2p4 the scene opened without a problem. I thought I would lost the scene file
     
    Last edited: Dec 10, 2015
  27. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    Did you check the editor log?

    It should have more info about what's going on. Also you could report the bug with the project, I'd take a look at it
     
  28. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    Ah, I didn't capture the 'initial' warnings when I first opened the project in Unity 5.3. The warning above was appeared when I deleted the lightmap data folder and re-import it after that.

    I think I'll have to stick to the Unity5.2.2p4, because the project dead line is at my nose and I can't risk any delay more... I'll try when I have some time. Thank you for your support.
     
  29. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    Sorry to bother you, it would be better for A/S if the project can be updated to Unity5.3, so I just reported the bug.(753068) The project file size is a lot heavy, unfortunately.
    If you could kindly review the project and find out what the problem is, it would be a lot of help to me. I really appreciate for your support. Thank you.
     
  30. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    Hey,

    checked it out, opens fine for me though.

    There were some compiler errors, but after fixing those - plays fine too.
     
  31. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    Oh.... Well, then that means there is something wrong in my computer, I guess??
    It didn't have a compiler error before I submit it, that's strange though...
    Maybe I'll have to look at it or(for the last resort) recreate the whole scene... Thank you for your help.
     
  32. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    It failed to load the scene on my macbook pro laptop too.(My laptop was sent for repair last week so I couldn't test the project on it) I tried and failed on an iMac before.
    What platform did you use? Windows?
    Maybe I'll have to open the project on an Unity 5.3 for Windows, save the project to 5.3, and then re-import the project on Mac OS.
     
  33. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    I'm on Win10, let's move this discussion to bug report emails as it's off-topic for this thread.
     
  34. RagtagChris

    RagtagChris

    Joined:
    Feb 24, 2014
    Posts:
    6
    Is this still on track to be fixed in 5.4? I didn't see it specifically mentioned on the roadmap, but I'm hoping its still a part of it. Thanks.
     
  35. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,199
    Yes, this is fixed in 5.4 and the fix is getting backported to 5.3 (should be in one of the next patch releases).
     
  36. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    387
    I have had the same prob, with "LightmapSnapshot' is inconsistent". It happend with an old sample-scene from unity assetstore, made with U_v5.00, wich i was studiing. Solution: Simply delete the LightMap and all other Maps generated from the "light"-tab. Also turn "auto-Bake" off. After this start a new baking. And et voila, you can publish it, open it.
     
  37. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    "Yes, this is fixed in 5.4 and the fix is getting backported to 5.3 (should be in one of the next patch releases)."​
    What is the state of this?
    We're stuck with Unity 5.3.3p2 (64-bit) because of some infinite loop bug on Windows Phone 8.1 and now discovered that the issue still persists, at least in that mentioned version and Unity 5.3.4f1 (64-bit).
     
unityunity