Skip to content

Commit aa63084

Browse files
AdamStrickUnityDeployer User
authored andcommitted
Combined HDAdditionalLightData LateUpdates (#93)
* Combined HDAdditionalLightdata LateUpdates * Wrapped with XP_CRAZYHUNTER define
1 parent bbdcb5c commit aa63084

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,11 +3068,17 @@ private void Start()
30683068
}
30693069

30703070
// TODO: There are a lot of old != current checks and assignation in this function, maybe think about using another system ?
3071-
void LateUpdate()
3071+
3072+
#if XP_CRAZYHUNTER
3073+
internal void DoLateUpdate()
3074+
{
3075+
#else
3076+
internal void LateUpdate()
30723077
{
30733078
// Prevent any unwanted sync when not in HDRP (case 1217575)
30743079
if (HDRenderPipeline.currentPipeline == null)
30753080
return;
3081+
#endif
30763082

30773083
// We force the animation in the editor and in play mode when there is an animator component attached to the light
30783084
#if !UNITY_EDITOR
@@ -3422,6 +3428,8 @@ void UpdateLightIntensity()
34223428

34233429
void Awake()
34243430
{
3431+
HDRPUpdates.LazyInit();
3432+
34253433
Migrate();
34263434

34273435
// We need to reconstruct the emissive mesh at Light creation if needed due to not beeing able to change hierarchy in prefab asset.
@@ -4175,7 +4183,7 @@ public ShadowMapType GetShadowMapType(HDLightType lightType)
41754183
/// <summary>Tell if the light is overlapping for the light overlap debug mode</summary>
41764184
internal bool IsOverlapping()
41774185
{
4178-
var baking = GetComponent<Light>().bakingOutput;
4186+
var baking = legacyLight.bakingOutput;
41794187
bool isOcclusionSeparatelyBaked = baking.occlusionMaskChannel != -1;
41804188
bool isDirectUsingBakedOcclusion = baking.mixedLightingMode == MixedLightingMode.Shadowmask || baking.mixedLightingMode == MixedLightingMode.Subtractive;
41814189
return isDirectUsingBakedOcclusion && !isOcclusionSeparatelyBaked;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#if XP_CRAZYHUNTER
2+
namespace UnityEngine.Rendering.HighDefinition
3+
{
4+
[ExecuteAlways]
5+
public class HDRPUpdates : MonoBehaviour
6+
{
7+
private static HDRPUpdates s_Instance;
8+
9+
internal static void LazyInit()
10+
{
11+
if (s_Instance == null)
12+
{
13+
GameObject go = new GameObject("HDRPUpdates");
14+
DontDestroyOnLoad(go);
15+
s_Instance = go.AddComponent<HDRPUpdates>();
16+
}
17+
}
18+
19+
private void LateUpdate()
20+
{
21+
// Prevent any unwanted sync when not in HDRP (case 1217575)
22+
if (HDRenderPipeline.currentPipeline == null)
23+
return;
24+
25+
var hdAdditionalLightDatas = HDAdditionalLightData.s_InstancesHDAdditionalLightData;
26+
int dataCount = hdAdditionalLightDatas.Count;
27+
28+
for (int i = dataCount - 1; i >= 0; i--)
29+
{
30+
hdAdditionalLightDatas[i].DoLateUpdate();
31+
}
32+
}
33+
}
34+
}
35+
#endif

com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDRPUpdates.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)