@@ -58,6 +58,25 @@ public override DepthTextureMode GetCameraFlags()
5858 return DepthTextureMode . Depth | DepthTextureMode . MotionVectors ;
5959 }
6060
61+ private void CreateTemporaryRT ( PostProcessRenderContext context , int nameID , int width , int height , RenderTextureFormat RTFormat )
62+ {
63+ var cmd = context . command ;
64+ #if UNITY_2017_2_OR_NEWER
65+ var rtDesc = context . GetDescriptor ( 0 , RTFormat , RenderTextureReadWrite . Linear ) ;
66+ rtDesc . width = width ;
67+ rtDesc . height = height ;
68+ #if UNITY_2019_1_OR_NEWER
69+ cmd . GetTemporaryRT ( nameID , rtDesc , FilterMode . Point ) ;
70+ #elif UNITY_2017_3_OR_NEWER
71+ cmd . GetTemporaryRT ( nameID , rtDesc . width , rtDesc . height , rtDesc . depthBufferBits , FilterMode . Point , rtDesc . colorFormat , RenderTextureReadWrite . Linear , rtDesc . msaaSamples , rtDesc . enableRandomWrite , rtDesc . memoryless , context . camera . allowDynamicResolution ) ;
72+ #else
73+ cmd . GetTemporaryRT ( nameID , rtDesc . width , rtDesc . height , rtDesc . depthBufferBits , FilterMode . Point , rtDesc . colorFormat , RenderTextureReadWrite . Linear , rtDesc . msaaSamples , rtDesc . enableRandomWrite , rtDesc . memoryless ) ;
74+ #endif
75+ #else
76+ cmd . GetTemporaryRT ( nameID , width , height , 0 , FilterMode . Point , RTFormat , RenderTextureReadWrite . Linear ) ;
77+ #endif
78+ }
79+
6180 public override void Render ( PostProcessRenderContext context )
6281 {
6382 var cmd = context . command ;
@@ -92,27 +111,23 @@ public override void Render(PostProcessRenderContext context)
92111 sheet . properties . SetFloat ( ShaderIDs . RcpMaxBlurRadius , 1f / maxBlurPixels ) ;
93112
94113 int vbuffer = ShaderIDs . VelocityTex ;
95- cmd . GetTemporaryRT ( vbuffer , context . width , context . height , 0 , FilterMode . Point ,
96- packedRTFormat , RenderTextureReadWrite . Linear ) ;
114+ CreateTemporaryRT ( context , vbuffer , context . width , context . height , packedRTFormat ) ;
97115 cmd . BlitFullscreenTriangle ( BuiltinRenderTextureType . None , vbuffer , sheet , ( int ) Pass . VelocitySetup ) ;
98116
99117 // Pass 2 - First TileMax filter (1/2 downsize)
100118 int tile2 = ShaderIDs . Tile2RT ;
101- cmd . GetTemporaryRT ( tile2 , context . width / 2 , context . height / 2 , 0 , FilterMode . Point ,
102- vectorRTFormat , RenderTextureReadWrite . Linear ) ;
119+ CreateTemporaryRT ( context , tile2 , context . width / 2 , context . height / 2 , vectorRTFormat ) ;
103120 cmd . BlitFullscreenTriangle ( vbuffer , tile2 , sheet , ( int ) Pass . TileMax1 ) ;
104121
105122 // Pass 3 - Second TileMax filter (1/2 downsize)
106123 int tile4 = ShaderIDs . Tile4RT ;
107- cmd . GetTemporaryRT ( tile4 , context . width / 4 , context . height / 4 , 0 , FilterMode . Point ,
108- vectorRTFormat , RenderTextureReadWrite . Linear ) ;
124+ CreateTemporaryRT ( context , tile4 , context . width / 4 , context . height / 4 , vectorRTFormat ) ;
109125 cmd . BlitFullscreenTriangle ( tile2 , tile4 , sheet , ( int ) Pass . TileMax2 ) ;
110126 cmd . ReleaseTemporaryRT ( tile2 ) ;
111127
112128 // Pass 4 - Third TileMax filter (1/2 downsize)
113129 int tile8 = ShaderIDs . Tile8RT ;
114- cmd . GetTemporaryRT ( tile8 , context . width / 8 , context . height / 8 , 0 , FilterMode . Point ,
115- vectorRTFormat , RenderTextureReadWrite . Linear ) ;
130+ CreateTemporaryRT ( context , tile8 , context . width / 8 , context . height / 8 , vectorRTFormat ) ;
116131 cmd . BlitFullscreenTriangle ( tile4 , tile8 , sheet , ( int ) Pass . TileMax2 ) ;
117132 cmd . ReleaseTemporaryRT ( tile4 ) ;
118133
@@ -122,17 +137,13 @@ public override void Render(PostProcessRenderContext context)
122137 sheet . properties . SetFloat ( ShaderIDs . TileMaxLoop , ( int ) ( tileSize / 8f ) ) ;
123138
124139 int tile = ShaderIDs . TileVRT ;
125- cmd . GetTemporaryRT ( tile , context . width / tileSize , context . height / tileSize , 0 ,
126- FilterMode . Point , vectorRTFormat , RenderTextureReadWrite . Linear ) ;
140+ CreateTemporaryRT ( context , tile , context . width / tileSize , context . height / tileSize , vectorRTFormat ) ;
127141 cmd . BlitFullscreenTriangle ( tile8 , tile , sheet , ( int ) Pass . TileMaxV ) ;
128142 cmd . ReleaseTemporaryRT ( tile8 ) ;
129143
130144 // Pass 6 - NeighborMax filter
131145 int neighborMax = ShaderIDs . NeighborMaxTex ;
132- int neighborMaxWidth = context . width / tileSize ;
133- int neighborMaxHeight = context . height / tileSize ;
134- cmd . GetTemporaryRT ( neighborMax , neighborMaxWidth , neighborMaxHeight , 0 ,
135- FilterMode . Point , vectorRTFormat , RenderTextureReadWrite . Linear ) ;
146+ CreateTemporaryRT ( context , neighborMax , context . width / tileSize , context . height / tileSize , vectorRTFormat ) ;
136147 cmd . BlitFullscreenTriangle ( tile , neighborMax , sheet , ( int ) Pass . NeighborMax ) ;
137148 cmd . ReleaseTemporaryRT ( tile ) ;
138149
0 commit comments