Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LWRP/URP Point Light issues

Discussion in 'General Graphics' started by RedMattis, Jan 14, 2020.

  1. RedMattis

    RedMattis

    Joined:
    Apr 18, 2015
    Posts:
    33
    I'm having some issues with point lights in my project. My end goal is to have a level mostly lit by torches and other point-light-type sources.

    Problem is, as you can see in the image the light ends up extremely harsh, yet at the same time it still doesn't stretch more than 5 or so meters away from it before it is nearly completely dark. I've tried changing the range and intensity parameter, but the range parameter doesn't seem to do much more than soft-limit the maximum range of the light. Meanwhile the intensity parameter results in much too extreme light.

    If I try to light up a ball-room sized environment with a point light it ends up almost pure white in the center and still dark grey in the corners. I'm sure the lights falloff is realistic and all that, but in an interior I'm sure light-bounces would make it effectively light up much more, but since simulating that isn't really an option...

    Is there no way to scale the range of the light without increasing the intensity?

    I'm using Unity's LWRP/URP rendering workflow. The background is using the standard "Universal Render Pipeline/Lit"-shader with a low Smoothness setting.

    upload_2020-1-14_22-3-57.png
     
  2. RedMattis

    RedMattis

    Joined:
    Apr 18, 2015
    Posts:
    33
    Here is another issue of the same thing, with a placeholder texture on the wall/floor, zoomed out, and with an even more intense light. Intensity 50, Range 10000 (not that the latter matters, setting it to 20 has the same result.)
    upload_2020-1-14_22-20-57.png
     
    LordCafe likes this.
  3. Shane_Michael

    Shane_Michael

    Joined:
    Jul 8, 2013
    Posts:
    158
    LWPR/URP uses physically correct falloff, and the range is just there as an optimization to fade it out early. In theory, the light never actually falls off to 0, but you can use the range to truncate it to a certain distance for efficiency. Using a very high value won't change the appearance of the light like it would with older "ad hoc" attenuation functions.

    I believe the only way to modify it is by creating a local copy of the URP and going into the ShaderLibrary/Lighting.hlsl file and modifying the attenuation function. If that is the only file you are changing, merging updates to the pipeline should be fairly easy. It might be nice if Unity provided some kind of shader configuration file to easily override functions like this because it seems to come up fairly often.
     
    RedMattis likes this.
  4. nathanburba

    nathanburba

    Joined:
    Aug 29, 2013
    Posts:
    1
    Go into lighting.hlsl and change "float lightAtten = rcp(distanceSqr);" to "float lightAtten = rcp(pow(distanceSqr, 0.15));" That made the attenuation actually usable for lighting dark environments. Modify 0.15 to something else to modify the curve.
     
    CosmicStud, rivanavur, Brady and 2 others like this.
  5. RedMattis

    RedMattis

    Joined:
    Apr 18, 2015
    Posts:
    33
    How exactly do I create a local copy? Simply making a backup of the package's folder and then uninstalling the Unity one and adding the folder gave a bunch of errors like this:

    Assets\UnityURP_Tweaked\ShaderLibrary\ShaderTypes.cs(5,10): error CS0246: The type or namespace name 'GenerateHLSLAttribute' could not be found (are you missing a using directive or an assembly reference?)
     
  6. Shane_Michael

    Shane_Michael

    Joined:
    Jul 8, 2013
    Posts:
    158
    You can add it through the package manager interface rather than simply copying it into your project. Then you can maintain your own version of the package either locally or on Github that you can easily add to multiple projects.
     
    GenaSG and RedMattis like this.
  7. RedMattis

    RedMattis

    Joined:
    Apr 18, 2015
    Posts:
    33
    I ended up writing a shader that handles light in a custom way, but knowing how to make local packages will probably be useful at some point later on anyway. Thanks. :)
     
  8. Navid38

    Navid38

    Joined:
    Dec 21, 2018
    Posts:
    5
    if you want to build for mobile, you need to change the color space form linear to Gamma,
    linear does not work on some mobile devices.
     
    Last edited: May 5, 2020
  9. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    This is still an issue on Unity 2021! Not noticeable by many developers. But point lights do not work on android build at far ranges, unless the URP package is removed and modified. Unity devs help please!
     
    akshith_s likes this.
  10. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    Just wondering, do you have a fix for URP 12? Thanks!
     
    L-Tyrosine likes this.
  11. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    2021.3.5 fixed the point light issue