Search Unity

GI Lightmap Issue with Day and Night

Discussion in 'Global Illumination' started by Olander, Aug 25, 2016.

  1. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    I have a weather system that has Dynamic Day/Night Cycling and this issue is driving me insane. Been trying to solve this for awhile now and just now truly figured out what is causing it. How to fix this....bug or not....no idea. Prior to actually making a bug report. Perhaps the forum collective has some other ideas?

    What is causing this seems to be the GI Lightmap that is being generated (Unintentional Baked GI??). The sequence below is repeatable so it is indeed the Lightmap. To see this in action it is a quick setup test. Making a new scene is really close to already set up.
    • Have all camera effects off...including turning off the FlareLayer.
    • Now rotate the directional light to say....7-8am and intensity to 1.0-1.25 for a nice day light look.
    • Add a box or plane or something at 0,0,0....this is our Horizon
    • Now add a couple spheres. 2 with Standard and 2 with Standard Specular.
    • Set 1 of each to 0.1 Smoothness for a Matte finish. The other 2 to 1.0 Smoothness and the Standard to 1.0 Metallic. Set you Specular Color to 15,15,15 (Very nice general spec color for many surfaces) on the 2 Standard Spec materials. Set the colors of each to what you want. I would also recommend adding a White Swatch to the Albedo/Diffuse but should not be necessary...Should Not. :)
    • You should now have 1 Metallic, 1 Glossy, 1 Standard Matte, and 1 Standard Spec Matte....Spheres.
    7am to 4:30am
    • Everything should look right in the scene and your Lightmap should have generated. (Pictures A shows this)
    • Now Press Play and rotate the directional light below the horizon and set the Light Intensity to ~0.1. The Skybox Shader should go dark. (Picture B shows this). You will see here that Residual Light is being calculated from something....Lightmap Data.
    4:30am to 7am
    • Now return to Edit Mode and rotate the light so the Skybox goes dark and set the Light Intensity to ~0.1. The scene should be dark....great for very dark nights. Now press play, rotate the directional light back up above the horizon and set the light intensity to 1.0-1.25 again. You will see what is happening. The materials are not responding and the lighting is just rendering terribly. (Picture C shows this).
    7am to 4:30am leaves the scene too Bright at Night
    4:30am to 7am leaves the scene too Dark at Day

    You can see in A that the Gloss and Metallic work just fine but the lighting is just far too bright at 0.1. In contrast once setting the light to 0.1 (no pic for this since the scene is very dark) then raising the light to 1.25 at the same exact angle you can see here that the light rendering is simply broken and the Gloss/Metallic are not rendering at all.

    This is indeed proof that the Lightmap is most definitely involved here and general ambient light may be miscalculated?
    So how do we resolve this? Is this intended behavior or is this a bug?

    Cheers
    O

    Picture A
    Unity 5.4 Lightmap Bug A.png

    Picture B
    Unity 5.4 Lightmap Bug B.png
    Picture C
    Unity 5.4 Lightmap Bug C.png
     
    Last edited: Aug 25, 2016
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,790
    Add a reflection probe and set it to update in realtime.

    Also make sure you have precompute enabled and that your directional light is set to realtime.
     
  3. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Not it. Here is a pic with the Reflection Probe. The reflection probe does help sort of resolve the Metallic but in the original Picture A there is not a want/need for reflections....only Gloss and Metallic/Smooth surface. The Gloss should have no Reflection in any case (or very very little) since it is simple a glossy non-reflective material....think of a new billiards ball.

    Also you can see here is that the lighting and shadowing is actually working but the Gloss is not. The main issue here is that at 7am which is exactly shown in the picture with Light Intensity 1.25 the 'Ambient Light' should be higher as it is when the Lightmap data is generated (baked)...as in Picture A shows.
    Unity 5.4 Lightmap Bug w Reflection Probe .png
     
  4. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    I found something I suppose may be related to this on the forums here. Perhaps this truly is intended behavior.
    Here is the link and it is explained fairly well by a forum member.
    http://forum.unity3d.com/threads/please-clear-the-gi-confusion.412622/#post-2756254

    It seems for a Day/Night Cycle (which worked in other Unity 5 versions) we need to be able to either mixed 2 lightmap data files or be able to disable light baking entirely. Not sure we have a solution at this point.
     
  5. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    I don't get what you're going for. If you want dynamic lighting then why are you using Baked GI?

    I guess the skybox reflections aren't being updated in realtime.

    You have a few options right now.
    • Fully Dynamic (direct) - dynamic lighting/shadows, no bounced .
      • Best for day/night cycle. Use Color/Gradient as your Ambient Source.
      • Bad for performance if many shadow casters.
    • Baked GI (direct + indirect) - baked lighting/shadows .
      • You can also have some dynamic lights without shadows for things like explosions.
      • Great for performance. Mobiles can run this.
    • Precomputed Realtime GI (direct + indirect) - Same as fully dynamic, except you get bounced/indirect lighting.
      • Invented so we can get the baked-quality indirect lighting, but in realtime. Also good for day/night cycles.
      • Bad for performance.
    Basically, for dynamic scenes, Baked GI should be disabled. Use Ambient Source Color/Gradient. Play with Reflection Intensity.

    Mixed lighting is available in a preview build of Unity here - http://forum.unity3d.com/threads/mixed-mode-fixes-and-lighting-window-preview-1-try-it.424991/
     
    Last edited: Aug 25, 2016
  6. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Thanks for the post. I have been using Realtime GI all along. The Baked GI portion is set to Auto in the Lighting Tab. If I turn it to Manual then I have to click that button to get any of the lighting to update in the scene. So I simply leave it at Auto.

    Precomputed Realtime GI works fine as long as the Ambient Light (Directional Light or Sun) stays in Day Light Hours. It works well with Static and Dynamic objects. What is happening with this is that it is Leaving Residual Lighting in the scene when Ambient Light is set to Low Levels. The Skybox is responding properly to the light angles and colors. The lighting is not reducing properly.
    *Picture A is very nice and shows really good lighting.
    *Picture B is showing the Residual Lighting the MUST BE removed from the scene with Low Light Intensity

    Fully Dynamic...this works in 5.2.2. Just tried it out in both Day/Night cycle and a dungeon/cave environment with low ambient lighting and flickering torches and candle lights. In 5.2.2 there some caveats to the dynamic lighting which can be worked around for a 'Good Enough' end result.

    The Day Lighting in 5.4.0 is much better...no argument there. I also have my options set up exactly as they were in 5.2.2. The lighting is indeed set to Realtime and I actually do use color control for the light color for both Day and Nights.

    Unity 5 Directional Light Settings .png
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,790
    There is no auto for baked gi.

    You mean the auto next to the build button at the bottom?

    Untick auto.

    Untick baked gi.

    In general, when given the choice between baked and realtime make sure you use realtime.

    Click the build button.
     
  8. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    @AcidArrow

    Okie. 1 more time. Attached is a Picture of my Lighting Tab. I have been using No Baked GI...meaning...Only Realtime Lighting/Rendering for all of my tests and calibrations. ONLY after this I begin adding Camera FX and other things that can and will affect lighting. Hence a reason for the color spheres in the pics. ;)

    I am not trying to be argumentative and appreciate the advice on settings to confirm. Especially for others who are also searching for the why behind this.

    The bottom line here is...How Do We Developers Working With the Unity 5.4 Engine as our Base Development Platform Rid Ourselves of the Residual Lighting in the Lightmap Data even when we are Not Baking the GI?

    This is something that has changed recently and I discovered this while calibrating my Night Weather scenarios in 5.4.0 specifically. I have been a Pro user since Unity 4 and am well versed in working around various version limitations. If there is a method to remove/change the Residual Light in a scene....I will try anything.

    Cheers
    O

    Note: The only thing different in this pic from normal is I unchecked the Auto toggle for you. Other than that...everything is as realtime as it gets.
    Unity 5 Lighting Tab Settings .png
     
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,790
    Do you want no kind of GI at all?

    Either enable precompute (so you have realtime gi)

    Or

    Clear all lightmap data (drop down on the build button) set ambient intensity to 0 and reflection intensity to 0.
     
  10. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    @AcidArrow

    Indeed there has to be full GI...or at least 'Good Enough GI' for acceptable Day and Night (Night includes indoor/underground places as well). I am completely fine with Good Enough. Night is not that now.

    So. I did exactly per your advice. I have tried both with and without Precompute as well as with and without the Build button. I also tried running with a cleared cache. So. Per your advice here are the exact pics.

    7am = 1.25 Directional Light Intensity with an almost white color
    4:30am = 0.1 Directional Light Intensity with a dark orange color (the gradient is progressing here to vary Dark Blue)
    *I am using 4:30am so you can see the light rim on the horizon and in the shader. The light is still at 0.1 intensity (Night)

    7am (GI was built at 4:30am...next pic)
    Unity 5.4 Lighting GI Bug Test A 0700.png

    4:30am (GI Build here at 0.1 Light Intensity)
    Unity 5.4 Lighting GI Bug Test A 0430.png
    7:00am (GI Build at 1.25 Light Intensity)
    Unity 5.4 Lighting GI Bug Test B 0700.png

    4:30am (Light Intensity at 0.1) This here shows the Residual Light left behind by the Build button
    Unity 5.4 Lighting GI Bug Test B 0430.png
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,790
    Are those spheres marked as lightmap static?

    If not, are there light probes in the scene?
     
  12. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Good point.
    I have marked them as both Static and not Static during testing. The Gloss/Shine is very important as I have materials that 'Gloss' when it rains and skin that also 'Glosses' when sweaty or wet. These cannot be set to static in any case and I do have custom shaders for those but they do still need to react to the Ambient Light properly....or pseudo GI.

    So here is a picture of my standard material setup for calibrations. The latest versions changed the Mesh Renderers section so in my mind from all the previous materials it makes less sense now....in any case this is how I have set them up. The Specular color varies slightly with each material but my solid starting point is 15,15,15 (Dark Charcoal).

    EDIT Note: I just tried my Hair and Skin Shader and they also suffer from residual light at night. The shaders work perfectly in Day hours.

    Lastly, I usually set the Blend Probes to Off. In this new version of the shader whether set to off or left at Blend Probes does not seem to make any difference since I am using full GI and no baked lighting of any sort.

    Thanks of advance. I am more than willing to do a Skype Share or even Teamviewer if you/someone knows how to solve this.
    Cheers
    O

    Unity 5 Standard Specular Sphere Setup.png
     
  13. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    @AcidArrow

    One more test I just tried. I added a Point Light and positioned it a meter above the Orange Sphere. You can see the settings in the picture. I set the shadow strength and it looks great at 7am and at 4:30am (Residual Directional Light is still left is Build is Clicked at 7am). Only 2 things missing at 4:30am. The Magenta Sphere is Glossy (StandSpec 1.0 Smoothness) and the Orange Sphere is all black which is set to the Metallic (Standard shader).

    Just thinking out load here. But this may be a combination of the new versions of the shader as well as the residual light being left behind during low Directional Lighting.

    Thoughts anyone?

    4:30am Test with a point light 1m above the Orange Sphere.
    Unity 5.4 Lighting GI Bug Test C 0430.png
     
    Last edited: Aug 25, 2016
  14. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    405
    Well. I do not give up easily. :cool::D

    I think I found the 'Good Enough Lighting' for the Nights. Still not quite right but it will be 'Good Enough' until the Unity 5.4+ lighting improvements come in. This should work just fine with those as well.
    *Caveat Here: The Sun/Directional Light must be in Day Light hours prior to pressing play.

    So I set the Ambient Source in the Lighting Tab to Gradient then needed to control both Sky Color and Equator Color in a gradient to get the right transference from Day to Night. I also had to set the Reflection Intensity to 0.5 to soften the ambient light. The result is solid (still tweaking the Equator Color Gradient for the best results). Also with this setup a 'General' Moon Light works very well without having to wrestle with the Directional Light. ;)

    As to whether this is a bug or not is still up for grabs since the Lighting is actually being worked on and improved now by Unity. So let us call this a decent enough work around. :)

    Below is the pic of my Lighting Tab and the results of the settings.
    Cheers
    O

    Unity 5 Lighting Tab Settings New .png

    7am
    Unity 5.4 Lighting GI Bug Test D 0700.png
    4:30am
    Unity 5.4 Lighting GI Bug Test D 0430.png
     
  15. ikefrc

    ikefrc

    Joined:
    Jul 3, 2012
    Posts:
    81
    Thanks for posting in my thread, I'm having exactly the same issue. I was also using a day and night cycle. I'll try to do what you did.