# ConvertToUnityFormat

> Converts light probes encoded as SphericalHarmonicsL2 to the format expected by the Unity renderer.

## Definition

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

## ConvertToUnityFormat(IDeviceContext, BufferSlice\<SphericalHarmonicsL2>, BufferSlice\<SphericalHarmonicsL2>, int)

Converts light probes encoded as [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) to the format expected by the Unity renderer.

```csharp
bool ConvertToUnityFormat(IDeviceContext context, BufferSlice<SphericalHarmonicsL2> irradianceIn, BufferSlice<SphericalHarmonicsL2> irradianceOut, int probeCount)
```

### Parameters

**** (\[IDeviceContext]\(/engine/6000.7/script-reference/unityengine/lighttransport/idevicecontext)): Device context.**** (\[BufferSlice\<SphericalHarmonicsL2>]\(/engine/6000.7/script-reference/unityengine/lighttransport/bufferslice1)): Buffer containing input irradiance.**** (\[BufferSlice\<SphericalHarmonicsL2>]\(/engine/6000.7/script-reference/unityengine/lighttransport/bufferslice1)): Output buffer containing the irradiance array after the conversion to the  format compatible with a Unity renderer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) probes to convert.

### Returns

| Type                                                          | Description                                                                       |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the operation was successfully added to the command queue on the context. |

### Remarks

The irradiance [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) light probes must satisfy the following conditions when used with a Unity renderer:

1. For L0 and L1, the coefficients must have the SH standard normalization terms folded into them (to avoid doing this multiplication in a shader).
2. The coefficients must be divided by Pi (π) for compatibility reasons. The divideByPI parameter controls this step.
3. L1 must be ordered as yzx (rather than xyz). The order is flipped back right before rendering in the GetShaderConstantsFromNormalizedSH function, before the [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) probes are passed to a shader.

## ConvertToUnityFormat(IDeviceContext, BufferSlice\<SphericalHarmonicsL2>, BufferSlice\<SphericalHarmonicsL2>, int, bool)

Converts light probes encoded as [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) to the format expected by the Unity renderer.

```csharp
bool ConvertToUnityFormat(IDeviceContext context, BufferSlice<SphericalHarmonicsL2> irradianceIn, BufferSlice<SphericalHarmonicsL2> irradianceOut, int probeCount, bool divideByPI)
```

### Parameters

**** (\[IDeviceContext]\(/engine/6000.7/script-reference/unityengine/lighttransport/idevicecontext)): Device context.**** (\[BufferSlice\<SphericalHarmonicsL2>]\(/engine/6000.7/script-reference/unityengine/lighttransport/bufferslice1)): Buffer containing input irradiance.**** (\[BufferSlice\<SphericalHarmonicsL2>]\(/engine/6000.7/script-reference/unityengine/lighttransport/bufferslice1)): Output buffer containing the irradiance array after the conversion to the  format compatible with a Unity renderer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) probes to convert.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to divide the coefficients by Pi (π), matching Unity's historical baked lighting convention. The overload without this parameter always divides. Pass false when the render pipeline disables [SupportedRenderingFeatures.divideBakedOutputByPI](/engine/6000.7/script-reference/unityengine/rendering/supportedrenderingfeatures/dividebakedoutputbypi.md) and expects textbook irradiance.

### Returns

| Type                                                          | Description                                                                       |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the operation was successfully added to the command queue on the context. |

### Remarks

The irradiance [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) light probes must satisfy the following conditions when used with a Unity renderer:

1. For L0 and L1, the coefficients must have the SH standard normalization terms folded into them (to avoid doing this multiplication in a shader).
2. The coefficients must be divided by Pi (π) for compatibility reasons. The divideByPI parameter controls this step.
3. L1 must be ordered as yzx (rather than xyz). The order is flipped back right before rendering in the GetShaderConstantsFromNormalizedSH function, before the [SphericalHarmonicsL2](/engine/6000.7/script-reference/unityengine/rendering/sphericalharmonicsl2.md) probes are passed to a shader.
