Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

LightProbes.SetSHCoefficientsSelf

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool SetSHCoefficientsSelf(SphericalHarmonicsL2[] coefficients);

Parameters

Parameter Description
coefficients The spherical harmonics coefficients to set.

Returns

bool true when the coefficients were successfully set. Otherwise false.

Description

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

When you change the spherical harmonics coefficients using this method, you must call LightProbes.Tetrahedralize or LightProbes.TetrahedralizeAsync to fully apply the changes.

Additional resources: LightProbes.GetSHCoefficientsSelf, LightProbes.countSelf, SphericalHarmonicsL2.

// Attach this script to a GameObject in a scene that contains baked light probes,
// then enter Play mode. The script gets the LightProbes object for the scene,
// and tints only the probes belonging to the scene with a specified color.

using UnityEngine; using UnityEngine.Rendering;

public class SetSHCoefficientsSelfExample : MonoBehaviour { public Color tint = new Color(1.0f, 0.6f, 0.6f);

void Start() { LightProbes probes = LightProbes.GetInstantiatedLightProbesForScene(gameObject.scene); if (probes == null || probes.countSelf == 0) { Debug.Log("The scene contains no baked light probes."); return; }

SphericalHarmonicsL2[] coefficients = probes.GetSHCoefficientsSelf(); for (int i = 0; i < coefficients.Length; i++) { for (int coefficient = 0; coefficient < 9; coefficient++) { coefficients[i][0, coefficient] *= tint.r; coefficients[i][1, coefficient] *= tint.g; coefficients[i][2, coefficient] *= tint.b; } }

probes.SetSHCoefficientsSelf(coefficients); LightProbes.Tetrahedralize(); } }