| Parameter | Description |
|---|---|
| coefficients | The spherical harmonics coefficients to set. |
bool
true when the coefficients were successfully set. Otherwise false.
Sets the spherical harmonics coefficients of the baked light probes stored in this LightProbes object.
When you change the spherical harmonics coefficients using this method, you must call LightProbes.Tetrahedralize or LightProbes.TetrahedralizeAsync to fully apply the changes.
Additional resources: LightProbes.GetSHCoefficientsSelf, LightProbes.countSelf, SphericalHarmonicsL2.
// Attach this script to a GameObject in a scene that contains baked light probes, // then enter Play mode. The script gets the LightProbes object for the scene, // and tints only the probes belonging to the scene with a specified color.
using UnityEngine; using UnityEngine.Rendering;
public class SetSHCoefficientsSelfExample : MonoBehaviour { public Color tint = new Color(1.0f, 0.6f, 0.6f);
void Start() { LightProbes probes = LightProbes.GetInstantiatedLightProbesForScene(gameObject.scene); if (probes == null || probes.countSelf == 0) { Debug.Log("The scene contains no baked light probes."); return; }
SphericalHarmonicsL2[] coefficients = probes.GetSHCoefficientsSelf(); for (int i = 0; i < coefficients.Length; i++) { for (int coefficient = 0; coefficient < 9; coefficient++) { coefficients[i][0, coefficient] *= tint.r; coefficients[i][1, coefficient] *= tint.g; coefficients[i][2, coefficient] *= tint.b; } }
probes.SetSHCoefficientsSelf(coefficients); LightProbes.Tetrahedralize(); } }