@@ -19,8 +19,13 @@ class AcrylicBlurRenderPass : ScriptableRenderPass
1919 {
2020 public bool setMaterialTexture = false ;
2121 private string profilerLabel ;
22+ #if UNITY_6000_0_OR_NEWER
23+ private RTHandle target1 ;
24+ private RTHandle target2 ;
25+ #else
2226 private RenderTargetHandle target1 ;
2327 private RenderTargetHandle target2 ;
28+ #endif
2429 private int downSample ;
2530 private int passes ;
2631 private string textureName ;
@@ -91,29 +96,48 @@ public override void Configure(CommandBuffer cmd, RenderTextureDescriptor camera
9196 }
9297 }
9398
99+ #if UNITY_6000_0_OR_NEWER
100+ private static RenderTargetIdentifier GetIdentifier ( RTHandle target )
101+ {
102+ return Shader . PropertyToID ( target . name ) ;
103+ }
104+
105+ #else
106+ private static RenderTargetIdentifier GetIdentifier ( RenderTargetHandle target )
107+ {
108+ return target . Identifier ( ) ;
109+ }
110+
111+ #endif
112+
94113 public override void Execute ( ScriptableRenderContext context , ref RenderingData renderingData )
95114 {
96115 CommandBuffer cmd = CommandBufferPool . Get ( profilerLabel ) ;
97116 cmd . Clear ( ) ;
98117
99- var handle = providedTexture == null ? target1 . Identifier ( ) : providedTexture ;
118+ var handle = providedTexture == null ? GetIdentifier ( target1 ) : providedTexture ;
100119 var renderer = renderingData . cameraData . renderer ;
120+ #if UNITY_6000_0_OR_NEWER
121+ var colorTargetHandle = renderer . cameraColorTargetHandle ;
122+ #else
123+ var colorTargetHandle = renderer . cameraColorTarget ;
124+ #endif
101125
102126 cmd . SetGlobalVector ( "_AcrylicInfo" , info ) ;
103127
104128 if ( downSample == 1 )
105129 {
106- cmd . Blit ( renderer . cameraColorTarget , handle ) ;
130+ cmd . Blit ( colorTargetHandle , handle ) ;
107131 }
108132 else if ( downSample == 2 )
109133 {
110134 cmd . SetGlobalVector ( "_AcrylicBlurOffset" , Vector2 . zero ) ;
111- LocalBlit ( cmd , renderer . cameraColorTarget , handle , blurMaterial ) ;
135+ LocalBlit ( cmd , colorTargetHandle , handle , blurMaterial ) ;
112136 }
113137 else
114138 {
115139 cmd . SetGlobalVector ( "_AcrylicBlurOffset" , 0.25f * pixelSize ) ;
116- LocalBlit ( cmd , renderer . cameraColorTarget , handle , blurMaterial ) ;
140+ LocalBlit ( cmd , colorTargetHandle , handle , blurMaterial ) ;
117141 }
118142
119143 if ( blur )
@@ -130,7 +154,7 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
130154
131155 if ( providedTexture == null && setMaterialTexture )
132156 {
133- cmd . SetGlobalTexture ( textureName , target1 . Identifier ( ) ) ;
157+ cmd . SetGlobalTexture ( textureName , GetIdentifier ( target1 ) ) ;
134158 }
135159
136160 context . ExecuteCommandBuffer ( cmd ) ;
@@ -145,15 +169,15 @@ private void QueueBlurPasses(CommandBuffer cmd, float[] widths)
145169 cmd . SetGlobalVector ( "_AcrylicBlurOffset" , ( 0.5f + widths [ i ] ) * pixelSize ) ;
146170 if ( providedTexture != null && i == widths . Length - 1 )
147171 {
148- LocalBlit ( cmd , target1 . Identifier ( ) , providedTexture , blurMaterial ) ;
172+ LocalBlit ( cmd , GetIdentifier ( target1 ) , providedTexture , blurMaterial ) ;
149173 }
150174 else if ( providedTexture != null && i == 0 )
151175 {
152- LocalBlit ( cmd , providedTexture , target1 . Identifier ( ) , blurMaterial ) ;
176+ LocalBlit ( cmd , providedTexture , GetIdentifier ( target1 ) , blurMaterial ) ;
153177 }
154178 else
155179 {
156- LocalBlit ( cmd , target1 . Identifier ( ) , target2 . Identifier ( ) , blurMaterial ) ;
180+ LocalBlit ( cmd , GetIdentifier ( target1 ) , GetIdentifier ( target2 ) , blurMaterial ) ;
157181 SwapTempTargets ( ) ;
158182 }
159183 }
@@ -174,6 +198,22 @@ private void SwapTempTargets()
174198 target2 = rttmp ;
175199 }
176200
201+ #if UNITY_6000_0_OR_NEWER
202+ private void ConfigureTempRenderTarget ( ref RTHandle target , string id , int width , int height , int slices , CommandBuffer cmd )
203+ {
204+ target = RTHandles . Alloc ( id , name : id ) ;
205+ if ( slices > 1 )
206+ {
207+ cmd . GetTemporaryRTArray ( Shader . PropertyToID ( target . name ) , width , height , slices , 0 , FilterMode . Bilinear ) ;
208+ }
209+ else
210+ {
211+ cmd . GetTemporaryRT ( Shader . PropertyToID ( target . name ) , width , height , 0 , FilterMode . Bilinear , RenderTextureFormat . ARGB32 ) ;
212+ }
213+
214+ ConfigureTarget ( target ) ;
215+ }
216+ #else
177217 private void ConfigureTempRenderTarget ( ref RenderTargetHandle target , string id , int width , int height , int slices , CommandBuffer cmd )
178218 {
179219 target . Init ( id ) ;
@@ -188,6 +228,7 @@ private void ConfigureTempRenderTarget(ref RenderTargetHandle target, string id,
188228
189229 ConfigureTarget ( target . Identifier ( ) ) ;
190230 }
231+ #endif
191232
192233
193234 public static float [ ] BlurWidths ( int passes )
0 commit comments