# GetSHCoefficientsSelf()

> Gets the spherical harmonics coefficients of the baked light probes stored in this LightProbes object.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public SphericalHarmonicsL2[] GetSHCoefficientsSelf()
```

### Returns

| Type                                                                                                      | Description                                                                                                                                    |
| --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [SphericalHarmonicsL2\[\]](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) | An array of [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) coefficients, one per probe. |

### Remarks

The returned array contains one [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) value for each light probe stored in this `LightProbes` object, in the same order as the positions returned by [LightProbes.GetPositionsSelf](/engine/6000.7/script-reference/unityengine/lightprobes/getpositionsself.md).

Additional Resources: [LightProbes.SetSHCoefficientsSelf](/engine/6000.7/script-reference/unityengine/lightprobes/setshcoefficientsself.md), [LightProbes.countSelf](/engine/6000.7/script-reference/unityengine/lightprobes/countself.md), [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md).

### Examples

```csharp
// Attach this script to a GameObject in a scene that contains baked light probes,
// then enter Play mode. The script reads the LightProbes object for the scene
// and logs the average spherical harmonics coefficients across all probes.

using UnityEngine;
using UnityEngine.Rendering;

public class GetSHCoefficientsSelfExample : MonoBehaviour
{
    void Start()
    {
        LightProbes probes = LightProbes.GetSharedLightProbesForScene(gameObject.scene);
        if (probes == null || probes.countSelf == 0)
        {
            Debug.Log("The scene contains no baked light probes.");
            return;
        }

        SphericalHarmonicsL2[] coefficients = probes.GetSHCoefficientsSelf();

        SphericalHarmonicsL2 sum = new SphericalHarmonicsL2();
        foreach (SphericalHarmonicsL2 sh in coefficients)
        {
            sum += sh;
        }
        SphericalHarmonicsL2 average = sum * (1.0f / coefficients.Length);

        for (int rgb = 0; rgb < 3; rgb++)
        {
            string channel = rgb == 0 ? "R" : rgb == 1 ? "G" : "B";
            for (int coefficient = 0; coefficient < 9; coefficient++)
            {
                Debug.Log($"Average {channel}[{coefficient}] = {average[rgb, coefficient]}");
            }
        }
    }
}
```
