Skip to content

Commit 86fae39

Browse files
authored
HDRP Compositor related fixes (#730)
* Fixes for the compositor test * Enable the compoositor test in build settings * Avoid gc alloc, hide internal components from vomume menu * Vulkan and DX12 screens, adjust compositor UI refresh
1 parent 0fd6c06 commit 86fae39

File tree

13 files changed

+228
-15
lines changed

13 files changed

+228
-15
lines changed
Lines changed: 2 additions & 2 deletions
Loading

TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/9800_Compositor.png.meta

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

TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/9800_Compositor.png.meta

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

TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/9800_Compositor.png.meta

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

TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ EditorBuildSettings:
572572
- enabled: 1
573573
path: Assets/GraphicTests/Scenes/9x_Other/9702_CustomPass_API.unity
574574
guid: 3d584f34970fc5c44871961e3178f4ce
575+
- enabled: 1
576+
path: Assets/GraphicTests/Scenes/9x_Other/9800_Compositor.unity
577+
guid: 708bd21bc204d2342bc1702a5a6de1d3
575578
- enabled: 1
576579
path: Assets/GraphicTests/Scenes/9x_Other/9801_ShurikenLightModule.unity
577580
guid: d50ee167e49a2d74988347d7888c3613

com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static partial class Styles
2222
CompositionManagerEditor m_Editor;
2323
Vector2 m_ScrollPosition = Vector2.zero;
2424
bool m_RequiresRedraw = false;
25+
float m_TimeSinceLastRepaint = 0;
2526

2627
[MenuItem("Window/Render Pipeline/HD Render Pipeline Compositor", false, 10400)]
2728
static void Init()
@@ -34,12 +35,16 @@ static void Init()
3435

3536
void Update()
3637
{
37-
// This ensures that layer thumbnails are updated every frame (for video layers)
38-
Repaint();
38+
m_TimeSinceLastRepaint += Time.deltaTime;
39+
40+
// This ensures that layer thumbnails are updated at least 4 times per second (redrawing the UI on every frame is too CPU intensive)
41+
if (m_TimeSinceLastRepaint > 0.25f)
42+
Repaint();
3943
}
4044

4145
void OnGUI()
4246
{
47+
m_TimeSinceLastRepaint = 0;
4348
CompositionManager compositor = CompositionManager.GetInstance();
4449
bool enableCompositor = false;
4550
if (compositor)

com.unity.render-pipelines.high-definition/Runtime/Compositor/AlphaInjection.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
namespace UnityEngine.Rendering.HighDefinition.Compositor
77
{
8-
[Serializable]
8+
// Injects an external alpha texture into the alpha channel. Used for controlling which pixels will be affected by post processing.
9+
// Use VolumeComponentDeprecated to hide the component from the volume menu (it's for internal compositor use only)
10+
[Serializable, VolumeComponentDeprecated]
911
internal sealed class AlphaInjection : CustomPostProcessVolumeComponent, IPostProcessComponent
1012
{
1113
internal class ShaderIDs
@@ -31,8 +33,8 @@ public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source,
3133
{
3234
Debug.Assert(m_Material != null);
3335

34-
//TODO: can we detect this before we get here?
35-
AdditionalCompositorData layerData = camera.camera.gameObject.GetComponent<AdditionalCompositorData>();
36+
AdditionalCompositorData layerData = null;
37+
camera.camera.gameObject.TryGetComponent<AdditionalCompositorData>(out layerData);
3638
if (layerData == null || layerData.layerFilters == null)
3739
{
3840
HDUtils.BlitCameraTexture(cmd, source, destination);

com.unity.render-pipelines.high-definition/Runtime/Compositor/ChromaKeying.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ namespace UnityEngine.Rendering.HighDefinition.Compositor
77
{
88
// Custom post-processing pass that performs chroma keying
99
// Shader adapted from: https://github.com/keijiro/ProcAmp
10-
[Serializable]
10+
// Use VolumeComponentDeprecated to hide the component from the volume menu (it's for internal use only)
11+
[Serializable, VolumeComponentDeprecated]
1112
internal sealed class ChromaKeying : CustomPostProcessVolumeComponent, IPostProcessComponent
1213
{
1314
internal class ShaderIDs
@@ -35,7 +36,8 @@ public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source,
3536
{
3637
Debug.Assert(m_Material != null);
3738

38-
AdditionalCompositorData layerData = camera.camera.gameObject.GetComponent<AdditionalCompositorData>();
39+
AdditionalCompositorData layerData = null;
40+
camera.camera.gameObject.TryGetComponent<AdditionalCompositorData>(out layerData);
3941

4042
if (activate.value == false || layerData == null || layerData.layerFilters == null)
4143
{

0 commit comments

Comments
 (0)