First off… Yay! Light falloffs now look much much nicer and light fades much more naturally.
But… I have some questions/feedback.
How can it actually be proper inv^2 if it’s still affected by “Range”? This really does not make sense. How can I have an intensity of 8 and a range of 5 and then have an intensity of 1 with the same range and then have both be inv^2?
Since you are reworking this, maybe it’s time to make Range not affect the intensity? Like I want a light that has a certain intensity and falls off properly. The range shouldn’t affect it. Range should just act as a cut off. This may make falloffs look weird if the range isn’t long enough, but that is easily fixable. Or maybe Unity could suggest an appropriate range for the intensity I want, so it cuts off at a part where light has lost most of its energy?
If I’m baking a light, I don’t really care about range anyway. Area lights don’t have range, emissive lights don’t have range. I understand it’s important in realtime, for performance purposes, but if I’m baking it I don’t really care about that.
Is everything now inv^2? By which I mean, is light coming from emissive surfaces also falling off properly? Is bounced light also falling off properly? If yes, then why do they look so different than direct lights?
Look at the image below, I have an area light (on the right) an emissive light with same size and intensity (middle) and a spot light on the left. I played around with the spotlight settings to try and make it look as close to the other two as possible, but it just won’t happen. Which makes me think that light falls off differently.
Sounds like a ton of falloff control is coming, which is cool, although from what little testing I did, they don’t seem to do anything in the progressive lightmapper.
And the point I’m trying to make, are the falloffs for indirect light/area lights etc also using inv^2? (they should be, but it doesn’t look like it)
@AcidArrow any news about the SetAllLightFalloffToInvSqr stuff?
surprisingly there’s lot of hidden stuff in 2017 with not sure why those thing are hidden
Programmable light falloff feature is not added to Progressive Lightmapper yet so it’s for Enlighten-only, but lighting team is currently working on it so it’ll soon be available
Yes, unfortunately it doesn’t work for realtime lights yet but it’s on the roadmap.
And also, for those who are interested in using the feature, here is a more user friendly script. By using this one, you can use Animation Curves to change the light falloff instead of hard-coding it and attach it to the light:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class CustomFalloff : MonoBehaviour
{
public AnimationCurve LightCurve;
[HideInInspector]Light lightComp;
// Calculate the falloff curve matching the built-in falloff in Unity.
const int kSampleCount = 13;
public float[] lookup = new float[kSampleCount];
public float[] table = new float[kSampleCount];
const float toZeroFadeStart = 0.8f * 0.8f;
private float[] samples;
void Update()
{
UpdateFalloff ();
//InverseSquare ();
}
void UpdateFalloff()
{
lightComp = GetComponent<Light>();
lookup[0] = 1;
lookup[1] = 1;
for (int i = 2; i < kSampleCount; i++)
{
lookup[i] = 1;
}
samples = new float[13];
for(int i = 0; i<samples.Length; i++)
{
table[i] = Mathf.Clamp01(LightCurve.Evaluate((float)i/12));
}
lightComp.SetFalloffTable(table);
}
void InverseSquare()
{
lightComp = GetComponent<Light>();
Light.SetAllLightsFalloffToUnityLegacy();
}
}