GetSHCoefficientsSelf()
Gets the spherical harmonics coefficients of the baked light probes stored in this LightProbes object.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public SphericalHarmonicsL2[] GetSHCoefficientsSelf()
Returns
Type | Description |
|---|---|
| SphericalHarmonicsL2[] | An array of SphericalHarmonicsL2 coefficients, one per probe. |
Remarks
The returned array contains one SphericalHarmonicsL2 value for each light probe stored in this object, in the same order as the positions returned by LightProbes.GetPositionsSelf.
LightProbesAdditional Resources: LightProbes.SetSHCoefficientsSelf, LightProbes.countSelf, SphericalHarmonicsL2.
Examples
// 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]}"); } } }}