Skip to content

Commit e92d4a3

Browse files
authored
Set the ColorGradingLUTPass render target in Configure #5
Set the ColorGradingLUTPass render target in Configure
2 parents 3b88d32 + dd4b95e commit e92d4a3

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

com.unity.render-pipelines.universal/Runtime/2D/Renderer2D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re
9797

9898
if (postProcessEnabled && postProcessFeatureSet == PostProcessingFeatureSet.Integrated)
9999
{
100-
m_ColorGradingLutPass.Setup(m_ColorGradingLutHandle);
100+
m_ColorGradingLutPass.Setup(m_ColorGradingLutHandle, ref renderingData);
101101
EnqueuePass(m_ColorGradingLutPass);
102102

103103
// When using Upscale Render Texture on a Pixel Perfect Camera, we want all post-processing effects done with a low-res RT,

com.unity.render-pipelines.universal/Runtime/ForwardRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re
258258

259259
if (generateColorGradingLUT)
260260
{
261-
m_ColorGradingLutPass.Setup(m_ColorGradingLut);
261+
m_ColorGradingLutPass.Setup(m_ColorGradingLut, ref renderingData);
262262
EnqueuePass(m_ColorGradingLutPass);
263263
}
264264

com.unity.render-pipelines.universal/Runtime/Passes/ColorGradingLutPass.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ColorGradingLutPass : ScriptableRenderPass
1616
readonly GraphicsFormat m_HdrLutFormat;
1717
readonly GraphicsFormat m_LdrLutFormat;
1818

19+
RenderTextureDescriptor lutTextureDescriptor;
1920
RenderTargetHandle m_InternalLut;
2021

2122
public ColorGradingLutPass(RenderPassEvent evt, PostProcessData data)
@@ -53,10 +54,26 @@ Material Load(Shader shader)
5354
m_LdrLutFormat = GraphicsFormat.R8G8B8A8_UNorm;
5455
}
5556

56-
public void Setup(in RenderTargetHandle internalLut)
57+
public void Setup(in RenderTargetHandle internalLut, ref RenderingData renderingData)
5758
{
5859
m_InternalLut = internalLut;
5960

61+
ref var postProcessingData = ref renderingData.postProcessingData;
62+
bool hdr = postProcessingData.gradingMode == ColorGradingMode.HighDynamicRange;
63+
int lutHeight = postProcessingData.lutSize;
64+
int lutWidth = lutHeight * lutHeight;
65+
var format = hdr ? m_HdrLutFormat : m_LdrLutFormat;
66+
67+
lutTextureDescriptor = new RenderTextureDescriptor(lutWidth, lutHeight, format, 0);
68+
lutTextureDescriptor.vrUsage = VRTextureUsage.None; // We only need one for both eyes in VR
69+
}
70+
71+
/// <inheritdoc />
72+
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
73+
{
74+
// Create and set the render target to the LUT texture.
75+
cmd.GetTemporaryRT(m_InternalLut.id, lutTextureDescriptor, FilterMode.Bilinear);
76+
6077
// (ASG) This is required, otherwise this pass has the default camera attachment, and the code in
6178
// ScriptableRenderer.Execute enables XR mode for this pass (when in forward color grading mode).
6279
// (John): I believe this is a bug in URP, and this should be set.
@@ -85,11 +102,7 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
85102
// Prepare texture & material
86103
int lutHeight = postProcessingData.lutSize;
87104
int lutWidth = lutHeight * lutHeight;
88-
var format = hdr ? m_HdrLutFormat : m_LdrLutFormat;
89105
var material = hdr ? m_LutBuilderHdr : m_LutBuilderLdr;
90-
var desc = new RenderTextureDescriptor(lutWidth, lutHeight, format, 0);
91-
desc.vrUsage = VRTextureUsage.None; // We only need one for both eyes in VR
92-
cmd.GetTemporaryRT(m_InternalLut.id, desc, FilterMode.Bilinear);
93106

94107
// Prepare data
95108
var lmsColorBalance = ColorUtils.ColorBalanceToLMSCoeffs(whiteBalance.temperature.value, whiteBalance.tint.value);

0 commit comments

Comments
 (0)