Info: Unity 2023.2.11f1, URP 16.0.5 (copied to local Packages folder). *
*You have to copy the Render Pipeline Core, Universal, and Shader Graph packages to your local packages folder, otherwise it’ll just use the base ones I think, reverting all changes you do.
**I’m doing the same thing on Unity 6000 with URP 17, still seems to work.
I’m looking to adjust the attenuation for point lights in two ways. Firstly to change the attenuation distance by a scalar, and secondly to change the attenuation exponent.
I’ve been digging around in the lighting.hlsl file for a while and either I’m more blind than usual or I’m missing where this can be changed. The goal is to have those 2 values be changeable in realtime. Where should these be set (or multiple places, don’t need to do it separately for Forward/Def?), and what’s the best way to pass those values along?
If we assume a super-simple point light attenuation as NdotL * (1 / pow(distance, 2)), you get this:
The first change is to the distance, scaling that factor by A. In this case, a factor of 1/3. So what you see is NdotL * (1 / pow(distance / 3), 2).
The second change is an adjustment to the attenuation exponent. In these 2 pics, I use exponent values of 1 and 3.
NdotL * (1 / pow(distance, 1))
NdotL * (1 / pow(distance, 3))
Demo pics done with an unlit Shader Graph. I don’t really want to do that since it means everything that relies on that in particular (and I’d have to hand-re-create Unity’s BRDF lighting model!), and I’d rather make small changes to the lighting calcs in one place and have everything else run Unity’s ‘default’ lighting model.