- Home /
Access the lightProbes.bakedProbes coefficients
Trying to access the coefficients of the currently baked light probes always returns 0, as if all the coefficients for all my baked probes are always 0. I know for a fact that the probes work - in the scene I can see them having different colours - but cannot get hold of them in the code.
Here is how I am trying to access the coefficients (script is called after placing some probes in the scene and baking them):
UnityEngine.Rendering.SphericalHarmonicsL2[] coeffs = LightmapSettings.lightProbes.bakedProbes;
//var coeffsProbe0r = coeffs[2][0, 0]; // [0-2, 0-8]
//var coeffsProbe0g = coeffs[1][1, 0];
List<float> coeffsEachProbe = new List<float>();
bool isThisABlackProbe = true;
int blackProbeCounter = 0;
for (int k = 0; k < coeffs.Length; ++k)
{
// coeffs[k].AddAmbientLight(Color.white);
isThisABlackProbe = true;
coeffsEachProbe.Clear();
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
if (coeffs[k][i, j] != 0)
{
isThisABlackProbe = false;
}
coeffsEachProbe.Add(coeffs[k][i, j]);
}
}
if(isThisABlackProbe)
{
blackProbeCounter++;
}
else
{
Debug.Log("Not a black probe!");
}
}
return;
If I add a breakpoint on the line containing isThisABlackProbe = false, this breakpoint is never hit and the blackProbeCounter is always equal to the total number of probes at the end. This would indicate that all the probes' coefficients are 0.
I know LightmapSettings.lightProbes.coefficients is now deprecated. This used to be the way to get hold of the coefficients before, but now using bakedProbes it just doesn't seem to work at all any more.
Please note I do not want to simply replace the coefficients with my own the way it is shown here: lightProbes.bakedProbes, but want to look at the existing coefficients and take decisions on whether to keep the probe or not based on them.
Thanks!