Search Unity

Question Colours of Lighting Settings do not .Lerp on Oculus build

Discussion in 'VR' started by SP4ZE, Mar 1, 2023.

  1. SP4ZE

    SP4ZE

    Joined:
    Jul 31, 2022
    Posts:
    9
    Heyy, so im working on day / night cycle. Which does the following - Lerps the camera background color - Lerps the fog color - lerps the ambient color - changes light intensity - changes reflection intensity (RenderSettings.reflectionIntensity) Script works fine in editor. However on Oculus Quest 2 only the light inensity changes. No color lerp Which settings should i toggle to possibly get it to work? tysm in advance

    Main part of code
    Code (CSharp):
    1. transform.Rotate(1f, 0, 0);
    2. dirLight.intensity += change;
    3. cam.backgroundColor = Color.Lerp(nightColor, dayColor, lerpProgress);
    4. RenderSettings.fogColor = Color.Lerp(nightColor, dayColor, lerpProgress);
    5. RenderSettings.ambientSkyColor = Color.Lerp(Color.black, Color.gray, lerpProgress);
    6. RenderSettings.reflectionIntensity += change;
    Screenshot 2023-03-01 at 6.30.37 PM.png Screenshot 2023-03-01 at 6.32.08 PM.png
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,057
    I am guessing it also doesn't work on a PC build.
    When in editor, the lighting settings apply realtime. In builds you need to recalculate the lighting settings with DynamicGI.UpdateEnvironment or something similar. Note that performance will suffer
     
    SP4ZE and nilagard like this.
  3. nilagard

    nilagard

    Joined:
    Jan 13, 2017
    Posts:
    77
    In alot of open world games you will see that the "Sun" or the light from the sky will be either static or update in stacatto. Once every 2-3 seconds or more. This is because recalculating the entire scene with thousands of gameobjects will be so taxing that every game where the lightwork is heavy it would require much tougher pc setups for everyone that is playing, which means less players to buy their games. I would strongly suggest you to find another route to take when working with lights.
     
    SP4ZE and DevDunk like this.
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,057
    Yepp, I think faking it with a shader is probably the most performant
     
    SP4ZE likes this.
  5. SP4ZE

    SP4ZE

    Joined:
    Jul 31, 2022
    Posts:
    9
    Oh, never knew this existed. Hopefully it works for VR, and will do the job, thx a lot!
     
    DevDunk likes this.
  6. SP4ZE

    SP4ZE

    Joined:
    Jul 31, 2022
    Posts:
    9
    Mine updates every 0.25 seconds, and shadows distance is very low, making only a small portion of the world casting shadows. But thats a lot for clarifying! I will need to optimise it