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.
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.)
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.
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.
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?)
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.
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.
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!