@@ -58,6 +58,25 @@ public override DepthTextureMode GetCameraFlags()
58
58
return DepthTextureMode . Depth | DepthTextureMode . MotionVectors ;
59
59
}
60
60
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
+
61
80
public override void Render ( PostProcessRenderContext context )
62
81
{
63
82
var cmd = context . command ;
@@ -92,27 +111,23 @@ public override void Render(PostProcessRenderContext context)
92
111
sheet . properties . SetFloat ( ShaderIDs . RcpMaxBlurRadius , 1f / maxBlurPixels ) ;
93
112
94
113
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 ) ;
97
115
cmd . BlitFullscreenTriangle ( BuiltinRenderTextureType . None , vbuffer , sheet , ( int ) Pass . VelocitySetup ) ;
98
116
99
117
// Pass 2 - First TileMax filter (1/2 downsize)
100
118
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 ) ;
103
120
cmd . BlitFullscreenTriangle ( vbuffer , tile2 , sheet , ( int ) Pass . TileMax1 ) ;
104
121
105
122
// Pass 3 - Second TileMax filter (1/2 downsize)
106
123
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 ) ;
109
125
cmd . BlitFullscreenTriangle ( tile2 , tile4 , sheet , ( int ) Pass . TileMax2 ) ;
110
126
cmd . ReleaseTemporaryRT ( tile2 ) ;
111
127
112
128
// Pass 4 - Third TileMax filter (1/2 downsize)
113
129
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 ) ;
116
131
cmd . BlitFullscreenTriangle ( tile4 , tile8 , sheet , ( int ) Pass . TileMax2 ) ;
117
132
cmd . ReleaseTemporaryRT ( tile4 ) ;
118
133
@@ -122,17 +137,13 @@ public override void Render(PostProcessRenderContext context)
122
137
sheet . properties . SetFloat ( ShaderIDs . TileMaxLoop , ( int ) ( tileSize / 8f ) ) ;
123
138
124
139
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 ) ;
127
141
cmd . BlitFullscreenTriangle ( tile8 , tile , sheet , ( int ) Pass . TileMaxV ) ;
128
142
cmd . ReleaseTemporaryRT ( tile8 ) ;
129
143
130
144
// Pass 6 - NeighborMax filter
131
145
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 ) ;
136
147
cmd . BlitFullscreenTriangle ( tile , neighborMax , sheet , ( int ) Pass . NeighborMax ) ;
137
148
cmd . ReleaseTemporaryRT ( tile ) ;
138
149
0 commit comments