Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

WebGL skybox ambient lighting differs from Standalone

Discussion in 'WebGL' started by Steva, Feb 17, 2016.

  1. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Hello,

    we change the skybox at runtime and afterward call "DynamicGI.UpdateEnvironment()". In standalone builds, this works flawlessy. In WebGL, at first the Ambient light results darker, but a second call to UpdateEnvironment() for a pinkish hue to the Ambient lighting.
    Using a "flat" ambient source gives no such problems.
    We're using Unity 5.3.2 P3 but had this problem since 5.1, possibly before that.

    This is the Standalone and desired result:
    webgl_standalone.jpg

    WebGL:
    webgl_first.jpg

    WebGL after a second UpdateEnvironment():
    webgl_second.jpg

    Any help is much appreciated.
    Thanks
     
  2. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Update: changing the Ambient Source at runtime from Skybox to Flat and back, and calling UpdateEnvironment() gives inconsistent results and different "hues" (but never the correct one).

    webgl_third.JPG
     
  3. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Real-time GI is not supported on Unity WebGL. Do you get consistent results if only using baked GI ?
     
  4. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Sorry i should have specified, we don't use GI. We just set skybox (and ambient source and / or reflection source) at runtime. This is our Lighting settings:
    snip.JPG

    I think the problem is the "Ambient Probe" (RenderSettings.ambientProbe) containing incorrect results, but i may be wrong. We thought about manually building the ambient probe but we lack the proper knowledge of spherical harmonics at the moment.

    Also, we use a cubemap in Reflection source because using Skybox source seems to not work entirely (also in standalone).

    Thanks again
     
  5. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Still having this problem, the SphericalHarmonicsL2 values of the ambient probe are slightly wrong (in a random way) in WebGL. Also happens in 5.4_b13.
     
  6. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    223
    We ran into this and spent half the week trying to figure it out - our solution was not to use any other ambient source than 'Color'. All the other values resulted in ... weirdness.
     
  7. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    We decided we'll just save the ambient probe values offline and apply them on our own instead of calling UpdateEnvironment().
     
  8. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    223
    I believe we actually tried that, and it still misbehaved. I may be wrong there though.
     
  9. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    What we do is set our environment as desired, call UpdateEnvironment (just in case) and only then set the RenderSettings.ambientProbe[i, j] floats.
    I believe any subsequent call that changes the GI / ambient settings may cause the probe values to be recalculated by Unity, if the ambient source is set to skybox.
     
    kenshin and AFrisby like this.