SetSHCoefficientsSelf(SphericalHarmonicsL2[])
Sets the spherical harmonics coefficients of the baked light probes stored in this LightProbes object.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public bool SetSHCoefficientsSelf(SphericalHarmonicsL2[] coefficients)
Parameters
The spherical harmonics coefficients to set.
Returns
Type | Description |
|---|---|
| bool | |
Remarks
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.
Examples
// 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(); }}