Skip to content

Commit d703a00

Browse files
Combined HDAdditionalLightData LateUpdates (#93)
* Combined HDAdditionalLightdata LateUpdates * Wrapped with XP_CRAZYHUNTER define
1 parent 327d296 commit d703a00

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
@@ -2587,11 +2587,17 @@ private void Start()
25872587
}
25882588

25892589
// TODO: There are a lot of old != current checks and assignation in this function, maybe think about using another system ?
2590-
void LateUpdate()
2590+
2591+
#if XP_CRAZYHUNTER
2592+
internal void DoLateUpdate()
2593+
{
2594+
#else
2595+
internal void LateUpdate()
25912596
{
25922597
// Prevent any unwanted sync when not in HDRP (case 1217575)
25932598
if (HDRenderPipeline.currentPipeline == null)
25942599
return;
2600+
#endif
25952601

25962602
// We force the animation in the editor and in play mode when there is an animator component attached to the light
25972603
#if !UNITY_EDITOR
@@ -2941,6 +2947,8 @@ void UpdateLightIntensity()
29412947

29422948
void Awake()
29432949
{
2950+
HDRPUpdates.LazyInit();
2951+
29442952
Migrate();
29452953

29462954
// We need to reconstruct the emissive mesh at Light creation if needed due to not beeing able to change hierarchy in prefab asset.
@@ -3690,7 +3698,7 @@ public ShadowMapType GetShadowMapType(HDLightType lightType)
36903698
/// <summary>Tell if the light is overlapping for the light overlap debug mode</summary>
36913699
internal bool IsOverlapping()
36923700
{
3693-
var baking = GetComponent<Light>().bakingOutput;
3701+
var baking = legacyLight.bakingOutput;
36943702
bool isOcclusionSeparatelyBaked = baking.occlusionMaskChannel != -1;
36953703
bool isDirectUsingBakedOcclusion = baking.mixedLightingMode == MixedLightingMode.Shadowmask || baking.mixedLightingMode == MixedLightingMode.Subtractive;
36963704
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)