Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Default Light Falloff for URP should be reverted to match Builtin

Discussion in 'Universal Render Pipeline' started by Rich_A, Jun 14, 2020.

  1. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Here is the same scene lightmapped in Built-In:



    And URP:



    This lighting might make sense for a realistic first-person game (HDRP), but not for URP.

    Unity, please revert the light falloff to match Builtin RP, or give us an easy option to change.

    There have been multiple threads on this topic from other posters.

    Fully realistic lighting falloff is not appropriate for stylised games, it simply looks worse with these settings, it is harder to fill rooms with colored lighting, and anyone using store assets built for builtin will need to change all lighting settings (unless they manually override the falloff)
     
    Last edited: Jun 14, 2020
  2. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Last edited: Jun 14, 2020
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    12,011
    I mean, personally, the light fall off should be a property under every light, because I might want to mix and match for each light.

    In any case,
    just add a

    public FalloffType fallOff;

    and set ld.falloff = fallOff; instead of forcing it inversesquared as the example script in the docs do.

    Sometimes just to be safe, you may need to reload the scene as well, but it should work.
     
    thelebaron likes this.
  4. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Experimental.GlobalIllumination;
    5. using UnityEngine.SceneManagement;
    6.  
    7. [ExecuteInEditMode]
    8. public class ExtractFalloff : MonoBehaviour
    9. {
    10.     public void OnEnable()
    11.     {
    12.         Lightmapping.RequestLightsDelegate testDel = (Light[] requests, Unity.Collections.NativeArray<LightDataGI> lightsOutput) =>
    13.         {
    14.             DirectionalLight dLight = new DirectionalLight();
    15.             PointLight point = new PointLight();
    16.             SpotLight spot = new SpotLight();
    17.             RectangleLight rect = new RectangleLight();
    18.             LightDataGI ld = new LightDataGI();
    19.  
    20.             for (int i = 0; i < requests.Length; i++)
    21.             {
    22.                 Light l = requests[i];
    23.                 switch (l.type)
    24.                 {
    25.                     case UnityEngine.LightType.Directional: LightmapperUtils.Extract(l, ref dLight); ld.Init(ref dLight); break;
    26.                     case UnityEngine.LightType.Point: LightmapperUtils.Extract(l, ref point); ld.Init(ref point); break;
    27.                     case UnityEngine.LightType.Spot: LightmapperUtils.Extract(l, ref spot); ld.Init(ref spot); break;
    28.                     case UnityEngine.LightType.Area: LightmapperUtils.Extract(l, ref rect); ld.Init(ref rect); break;
    29.                     default: ld.InitNoBake(l.GetInstanceID()); break;
    30.                 }
    31.  
    32.                 ld.falloff = FalloffType.Legacy;
    33.                 lightsOutput[i] = ld;
    34.             }
    35.         };
    36.  
    37.         Lightmapping.SetDelegate(testDel);
    38.     }
    39.  
    40.     void OnDisable()
    41.     {
    42.         Lightmapping.ResetDelegate();
    43.     }
    44. }
    Any idea if changing the script example from 'InverseSquared' to 'Legacy' in line32 of the snippet above will produce the desired result? It doesn't seem to be, when initiating a new lightmap and clearing GI cache.

    I usually work with a programmer, but need to carry out pre-production experiments myself. I appreciate the tips :)

    Edit: oh boy, this has to be done for every light in the project? Any way to simply set this as the default for the entire project?
     
    Last edited: Jun 14, 2020
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    12,011
    For every scene, not every light.

    And it certainly works for built-in, I use it to switch some scenes to used baked inverse squared instead of legacy in built-in.

    I haven't tried with URP but I assume ti works.
     
  6. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Thanks for the help. I was able to approximate the lighting (realtime and baked) of Legacy in URP using the linear setting, as well as overriding the lighting.hlsl code, and bumping up albedo and indirect lighting settings in the lightmapper.

    It still doesn't look precisely like builtin, a bit worse, but its running at 500fps on URP and 300fps on builtin.
     
    Last edited: Jun 15, 2020
  7. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    343
    Hi, how did you do that? Where is that shader exactly?
     
  8. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    2,244
    Thats curious, one of my main issues when trying to convert was the fact it wasnt like for like.. That once converted it didnt look remotely like it used to.