ドキュメント

Unity Engine

Unity Engine

GetSHCoefficientsSelf()

Gets the spherical harmonics coefficients of the baked light probes stored in this LightProbes object.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

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
LightProbes
object, in the same order as the positions returned by LightProbes.GetPositionsSelf.

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]}"); } } }}