@@ -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,9 +54,30 @@ 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 ;
60+
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+
77+ // (ASG) This is required, otherwise this pass has the default camera attachment, and the code in
78+ // ScriptableRenderer.Execute enables XR mode for this pass (when in forward color grading mode).
79+ // (John): I believe this is a bug in URP, and this should be set.
80+ ConfigureTarget ( m_InternalLut . Identifier ( ) ) ;
5981 }
6082
6183 /// <inheritdoc/>
@@ -80,11 +102,7 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
80102 // Prepare texture & material
81103 int lutHeight = postProcessingData . lutSize ;
82104 int lutWidth = lutHeight * lutHeight ;
83- var format = hdr ? m_HdrLutFormat : m_LdrLutFormat ;
84105 var material = hdr ? m_LutBuilderHdr : m_LutBuilderLdr ;
85- var desc = new RenderTextureDescriptor ( lutWidth , lutHeight , format , 0 ) ;
86- desc . vrUsage = VRTextureUsage . None ; // We only need one for both eyes in VR
87- cmd . GetTemporaryRT ( m_InternalLut . id , desc , FilterMode . Bilinear ) ;
88106
89107 // Prepare data
90108 var lmsColorBalance = ColorUtils . ColorBalanceToLMSCoeffs ( whiteBalance . temperature . value , whiteBalance . tint . value ) ;
0 commit comments