Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Ambient light isn't working as expected

Discussion in 'Global Illumination' started by Alex_May, Nov 1, 2020.

  1. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    196
    Hey,

    I'm trying to light a corridor prefab, so I've turned off the sky and the sun and all other lights so I can tune the ambient light. However, it seems the ambient light is coming from outside the corridor, not from everywhere as stated in the manual and how I'd expect it to be.

    Here's the corridor:
    upload_2020-11-1_18-31-57.png

    Here's my environment light settings

    upload_2020-11-1_18-32-15.png

    Here's scene lighting

    upload_2020-11-1_18-32-34.png


    Now does someone wanna tell me why the middle of that corridor is dark and the end is light :S
     
  2. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    196
    2020.2.0b2 btw
     
  3. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    196
  4. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    551
    If meshes reflect their surrounding, like specular and metallic shaders, they need to be placed within a separate reflection probe, that actually captures the "dark corridor". Otherwise the skybox will be used which looks incorrect for indoor maps.
     
  5. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    196
    The point is that ambient light should be ambient, not emanating from the sky.
     
  6. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,319
    What you are referring to as ambient and the built in diffuse environment lighting are two different things. If you want a constant ambient term, you can add a contant color in your shader or disable baked / precomputed realtime GI.
     
  7. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    196
    I disagree that they are different things. If they were different things then they should be named differently. Also according to the Learn article, the same slider does different things depending on what other options are set. How can you explain this - the manual says that ambient light has no source, yet the ambient light clearly has a source (the sky)?
     
  8. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    275
    I've gotten around this by using 6 baked directional non-shadow lights, each pointed on a different axis. The colors are set to the ambient colors I was previously using in the lighting tab. Works pretty well.
     
  9. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    86
    Hi Alex_May. To avoid potential confusion/misunderstanding, let me first point out how Unity treats ambient/environment light currently. If you disable Skybox in Lighting > Environment and instead choose a single color in Environment Light, Unity currently works like this:
    • Dynamic objects and static objects without lightmaps have the single-color environment light applied in realtime regardless whether their surroundings are blocked by other geometry or not.
    • Static objects with baked lightmaps will not be affected by the single-color environment. Instead, they will pick up indirect light from their lightmap. This includes occlusion, i.e. objects blocking the surrounding incoming environment light.
    I show this behavior in this GIF:
    env-light.gif

    This may explain why your corridor is dark. Is it static and have you baked a lightmap for it? If so it "should" be darkened (according to the current intended behavior of Unity which arguably may not be ideal). I suggest you try to make your corridor objects dynamic and/or clearing the baked lighting. You can clear the lighting by pressing the small arrow next to "Generate Lighting". Does this resolve the particular issue for you?

    Whether "Ambient Light" and "Environment Light" is the same thing or not, depends on what we mean. If we by "Ambient Light" mean light coming from all directions everywhere and we by "Environment Light" mean light that originates from the infinitely far way environment (e.g. skybox) and reaches a surface via the process of physical light bounces, then they are clearly not the same. One is occluded, the other is not. If we by both "Ambient Light" and "Environment Light" refer to the light term controlled by the "Environment Light" section in the Lighting window, then they are the same.

    The fact that we are discussing this in the first place is perhaps a signal that something is not ideal in the product or in the manual. You mention that the current behavior contradicts the manual. I assume that you here implicitly refer to the page Ambient Light which says that ambient light "is light that is present all around the Scene". I agree that "all around the scene" includes inside corridors and that this presents a discrepancy between the manual and the actual product behavior.

    So I see two resolutions:
    1. We update the manual to reflect the current behavior. I.e. we make it clear that "Ambient Light" can mean different things depending on how you light an object.
    2. We update the current behavior to reflect the manual. I.e. we change the behavior of the lightmapper so that "Environment Light" (as it is called in the Lighting UI) affects lightmapped objects like it affects dynamic objects (no blocking of light).
    My guess is that the current behavior is preferred by most people simply because it is more realistic but that is just a gut feeling. Therefore I think 1) is the better solution.
     
    Last edited: Nov 11, 2020
  10. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    275
    The default should be changed such that it is less confusing, and an additional toggle should be added to allow environment light to be obscured. Or maybe, split the options such that an upgraded projects Ambient Settings become Baked Environment Settings, and the new default behaves in a more predictable way (with Ambient not being obscured, but Environment being obscured).

    At the very least, you could recommend doing the directional light hack I mentioned above, in the documentation. I know many artists who have simply given up on Unity's baked lighting, because they could not figure out how to get ambient lighting in, and assumed something was just broken in Unity.
     
  11. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    196
    Thank you for the detailed reply, that is amazing. Thank you very much.

    I think that the manual should be updated, and possibly something should be renamed somewhere... changing behaviour will upset a lot of people. The main thing is to detail how things work so that people can understand whether the engine does what they want / are expecting or not.

    Workarounds such as adding an ambient term in the shader or using directional lights as in funkyCoty's posts are just a fact of life in game dev. We solve problems and sometimes the problems are annoying and we come on the forums with an attitude like I did in this thread. So, sorry for my terse posts and thanks to everyone in this thread for helping and explaining things.
     
    rasmusn likes this.
  12. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    272
    I'm playing around with/learning to use light probes ... it seems that anything set to use light probes will completely ignore Environmental Lighting/Ambient Color, static and dynamic. Is that intended?

    FWIW ... I think I'd expect Ambient Color to apply to everything - baked/static/dynamic/light-probe-using ... changing it does seem to trigger light baking, not sure why!
     
unityunity