Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

URP, change light range behavior

Discussion in 'Universal Render Pipeline' started by xDenny8, Feb 4, 2020.

  1. xDenny8

    xDenny8

    Joined:
    Feb 12, 2017
    Posts:
    13
    Hello,

    I recently updated my project from built-in renderer to URP. But now all lights in the scene are broken. As I understand, Light range parameter behaves differently now. I dont know if its intended but now, for light to be even visible, I have to increase intensity to pretty high amounts.. problem is, that it does not allow me to extend the range of the light across entire room/hallway without increasing intensity too much. But increasing intensity to the point, where the light covers entire room will cause very bright spot in the middle (center of point light). Of course, it is logical for the light to be much brighter in the center but in built in renderer, I could compensate this with said light range. That allowed me to use 1 or 2 point lights, to enlighten entire hallway... now I am forced to use much more lights so it doesn't look bad. (which I would like to avoid if possible)

    I managed to fix the "problem" in Lighting.hlsl but that was just testing/temporary solution.

    My question is: can I somehow override this light attenuation permanently within C# code ? I am very new to SRP but I keep hearing that SRPs are highly customizable via C# scripts so I was wondering if someone could help me out.

    Thank you.
     
  2. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Posts:
    49
    Same here - Point Lights behave very differently in URP. Fixes in Lighting.hlsl didn't really help that much to me.
     
  3. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    Overall, converting a project to URP makes everything much darker. Even with a directional light. Increasing light intensity is not a solution, since, as you said, it creates bright spots ruining the overall look.
    Not exactly sure how to deal with this...
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Open the example scene and drop your assets in. How do they look? if it's still screwed, it's actually your textures or tone mapping/grading or baked lighting/probe/reflection.

    It's not necessarily the lights.
     
  5. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    Just did that.
    The URP sample scene has light intensity set to 2 but then slightly compensates with tonemapping in post.
    Disable post processing and bring light intensity to 1, and it looks exactly like in my own scene, which is much darker than the same settings with built-in renderer.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    You've got to contend with exposure and all sorts, things that were enabled in one pipeline but disabled by default or different in another pipeline.

    When lights are out of whack it's usually time to think about "what else makes things look lit differently?" and that's probes, tone mapping, grading, and especially exposure.
     
  7. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    What exposure and all sorts?
    I've disabled everything and set all settings to low in both projects.
    1. It's a bare bones default scene with no Post Processing in both projects.
    2. Both projects set to Gamma color space.
    3. Both projects shadows disabled, HDR disabled. Quality settings set to low (similarly adjusted RP profile for URP)
    4. Material Basemap color set to white in both Projects (No idea why it defaults to gray)
    What else is there to adjust?
     
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Gamma is bad, you should only use gamma ever, for ancient mobile hardware that's ES2 only (very low budget phones). That alone is messing stuff up, before anything else.

    For importing textures:

    You should be using Linear, and ensure that textures with colour information have sRGB ticked but mask maps and data textures have it unticked.

    If your game was gamma to begin with and ported to a Linear-native pipeline, you can expect some differences. URP will support gamma, but it might not behave the same way.
     
  9. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    I've converted both projects to Linear and while there is still a small difference, it is mostly negligible.


    Unity 3D template defaults to Gamma. I've also read that Linear might negatively impact performance on mobile, so that's the main reason I kept it in Gamma mode. I've just quickly checked market share for ES2 phones, and it's ~20%, which is not a small number.
    I'll have to look into performance implications.
     
  10. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,046
    Just an update: Tested Linear performance yesterday. While with post-processing disabled the game was running at 60 fps, with post-processing enabled fps dropped by 5-7 fps in linear mode.
     
  11. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    99
    It looks like URP triest to preserver the same look without caring about you choosing Gamma or Linear, but because that look is the Linear one, it means that transitioning from built-in Gamma to URP is not that easy.
    I'm also seeing that lightprobes are all in linear space always, even when I have selected gamma space in the player settings. I can't find a way to fix it

    [Edit] I fixed it. Unity's SRP doesn't account for gamma when sampling Lightprobes in the shader like Builtin did. Specifically, inside UnityCG.cginc has:

    Code (CSharp):
    1. #ifdef UNITY_COLORSPACE_GAMMA
    2.         res = LinearToGammaSpace (res);
    3. #endif
    But this check for gamma isn't present in EntityLighting.hlsl (SRP core package), so the lightprobe value sampled with SRP is wrong when using gamma.
     
    Last edited: Jun 8, 2020
unityunity