# SphericalHarmonicsL2

> Spherical harmonics up to the second order (3 bands, 9 coefficients).

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.Rendering](/engine/6000.0/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<SphericalHarmonicsL2>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct SphericalHarmonicsL2 : IEquatable<SphericalHarmonicsL2>
```

## Remarks

Spherical harmonics (SH) represent a function or signal over directions, and are commonly used in computer graphics to efficiently evaluate smooth lighting. Unity uses them for [LightProbes](/engine/6000.0/script-reference/unityengine/lightprobes.md) and environment lighting.

L2 spherical harmonics is composed of 9 coefficients for each color channel.

Additional Resources: [RenderSettings.ambientMode](/engine/6000.0/script-reference/unityengine/rendersettings/ambientmode.md), [RenderSettings.ambientProbe](/engine/6000.0/script-reference/unityengine/rendersettings/ambientprobe.md), [LightProbes](/engine/6000.0/script-reference/unityengine/lightprobes.md).

## Properties

| Property                                                                                       | Description                        |
| ---------------------------------------------------------------------------------------------- | ---------------------------------- |
| [this\[\]](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/item.md) | Access individual SH coefficients. |

## Methods

| Method                                                                                                                   | Description                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| [AddAmbientLight](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/addambientlight.md)         | Add an ambient light to the spherical harmonics.                                                                       |
| [AddDirectionalLight](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/adddirectionallight.md) | Add a directional light to the spherical harmonics.                                                                    |
| [Clear](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/clear.md)                             | Clears the spherical harmonics coefficients to zero.                                                                   |
| [Evaluate](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/evaluate.md)                       | Evaluates the spherical harmonics for each given direction. The directions and results arrays must have the same size. |

## Operators

| Operator                                                                                                   | Description                                            |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [operator +](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/op-addition.md)    | Adds two spherical harmonics.                          |
| [operator ==](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/op-equality.md)   | Returns true if the spherical harmonics are equal.     |
| [operator !=](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/op-inequality.md) | Returns true if the spherical harmonics are different. |
| [operator \*](/engine/6000.0/script-reference/unityengine/rendering/sphericalharmonicsl2/op-multiply.md)   | Scales SH by a given factor.                           |
