Skip to content

Commit d38d27c

Browse files
belgaardEvergreen
authored andcommitted
Added two tests
1 parent 0c0de8d commit d38d27c

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.ReflProbeNormalization.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using Unity.Collections;
34
#if UNITY_EDITOR
@@ -25,6 +26,7 @@ public class AdditionalGIBakeRequestsManager
2526
public static AdditionalGIBakeRequestsManager instance { get { return s_Instance; } }
2627

2728
const float kInvalidSH = 1f;
29+
const float kInvalidValidity = 1f;
2830
const float kValidSHThresh = 0.33f;
2931

3032
private static Dictionary<int, SphericalHarmonicsL2> m_SHCoefficients = new Dictionary<int, SphericalHarmonicsL2>();
@@ -64,6 +66,7 @@ public void DequeueRequest(int probeInstanceID)
6466
/// <param name ="sh"> The output SH coefficients that have been computed.</param>
6567
/// <param name ="pos"> The position for which the computed SH coefficients are valid.</param>
6668
/// <returns>Whether the request for light probe rendering has been fulfilled and sh is valid.</returns>
69+
[Obsolete("Use RetrieveProbe instead.", false)]
6770
public bool RetrieveProbeSH(int probeInstanceID, out SphericalHarmonicsL2 sh, out Vector3 pos)
6871
{
6972
if (m_SHCoefficients.ContainsKey(probeInstanceID))
@@ -78,6 +81,32 @@ public bool RetrieveProbeSH(int probeInstanceID, out SphericalHarmonicsL2 sh, ou
7881
return false;
7982
}
8083

84+
/// <summary>
85+
/// Retrieve the result of a capture request, it will return false if the request ID is invalid.
86+
/// </summary>
87+
/// <param name ="probeInstanceID"> The instance ID of the probe doing the request.</param>
88+
/// <param name ="pos"> The position for which the computed SH coefficients are valid.</param>
89+
/// <param name ="sh"> The output SH coefficients that have been computed.</param>
90+
/// <param name ="validity"> The output validity that has been computed.</param>
91+
/// <returns>True if the request ID is valid.</returns>
92+
public bool RetrieveProbe(EntityId probeInstanceID, out Vector3 pos, out SphericalHarmonicsL2 sh, out float validity)
93+
{
94+
if (m_SHCoefficients.ContainsKey(probeInstanceID))
95+
{
96+
sh = m_SHCoefficients[probeInstanceID];
97+
pos = m_RequestPositions[probeInstanceID];
98+
validity = m_SHValidity[probeInstanceID];
99+
100+
return true;
101+
}
102+
103+
sh = new SphericalHarmonicsL2();
104+
pos = Vector3.negativeInfinity;
105+
validity = float.NegativeInfinity;
106+
107+
return false;
108+
}
109+
81110
static internal bool GetPositionForRequest(int probeInstanceID, out Vector3 pos)
82111
{
83112
if (m_SHCoefficients.ContainsKey(probeInstanceID))

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,9 @@ public virtual void PrepareCulling() { }
791791
internal void TryUpdateLuminanceSHL2ForNormalization()
792792
{
793793
#if UNITY_EDITOR
794-
m_HasValidSHForNormalization = AdditionalGIBakeRequestsManager.instance.RetrieveProbeSH(GetInstanceID(), out m_SHForNormalization, out m_SHValidForCapturePosition);
794+
const float kValidSHThresh = 0.33f; // This threshold is used to make the code below functionally equivalent to the obsolete RetrieveProbeSH.
795+
m_HasValidSHForNormalization = AdditionalGIBakeRequestsManager.instance.RetrieveProbe(GetEntityId(), out m_SHValidForCapturePosition, out m_SHForNormalization, out float validity);
796+
m_HasValidSHForNormalization = m_HasValidSHForNormalization && validity < kValidSHThresh;
795797
if (m_HasValidSHForNormalization)
796798
m_SHValidForSourcePosition = transform.position;
797799
#endif

0 commit comments

Comments
 (0)