Search Unity

Ambient Light?

Discussion in 'Unity 5 Pre-order Beta' started by Seith, Jan 21, 2015.

  1. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    713
    Hey guys, I was wondering: is the concept of Ambient Light still valid in 5.0? In 4.6 and prior it used to be found in the Render Settings window (http://docs.unity3d.com/Manual/class-RenderSettings.html) along with Fog. And it could be used to lighten or darken the entire scene.

    Is that still something available? And if so where is it located now?
     
  2. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,286
    The scene tab of Window->Lighting

    Note it has more options now.
     
  3. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    713
    Thank you Elbows, got it!
     
  4. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    4,765
    Ambient lighting didn't seem to work like I expected. Didn't seem to affect lightmapping at all or lightmapped objects at all. Only objects that were marked as non-static were affected.
     
  5. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    713
    I'm also seeing the same behavior: the ambient light does not seem to affect my scene (my shaders are created through Shader Forge).
     
  6. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    200
    I also wonder the same thing. I don't think it is a bug but why it does not affect the lightmap static objects as we expect. Some one knows this?
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,937
    as far as i can say: "ambient source" = "skybox" does not work as expected when using lightmaps on mobile platforms. it works on opengl however. "ambient source" = "gradient" works on all platforms i have tested so far.

    @Seith: you may have to have a look into the generated shader code. either in the vertex or the fragment shader their must be a call for "ShadeSH9", "ShadeSH3Order" or "ShadeSH12Order" – otherwise there will no ambient diffuse lighting be applied.

    cheers, lars
     
  8. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    713
    I see. I'm using Shader Forge to create my shaders and there is an option in there in order to have your shader be affected by the ambient light. Trouble is, it's activated and yet the effect isn't quite visible...
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,937
    could you send or post the created shader file?
     
  10. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    713
    Sure, here's a very simple shader; I can change the ambient light from black all the up to white without any visible change on materials based on this guy.

    (Also, I'm in Deferred + Linear + DX11)
     

    Attached Files:

  11. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    713
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,937
    hi seith,
    your shader does not support deferred but only forward and legacy deferred. so it will be rendered using forward.

    as i am not familiar with shader forge i do not know if this is a general solution or will have to look different in other shaders but here it comes:

    comment lines:
    indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb*2; // Ambient Light

    --> We do not use UNITY_LIGHTMODEL_AMBIENT here as we want to add SH lighting

    add lines:
    indirectDiffuse += ShadeSH9(half4(normalDirection, 1.0)) * (1.0/_DiffuseExponent);
    or:
    indirectDiffuse += ShadeSH9(half4(normalDirection, 1.0));
    --> Depending on how the custom "_DiffuseExponent" should influence ambient lighting.

    this adds per pixel spherical harmonic ambient lighting.
    it does not add gi or reflection probes.

    lars