@@ -27,7 +27,7 @@ half3 _TaaParams; // Jitter.x, Jitter.y, Blending
2727// CoC calculation
2828half4 FragCoC (VaryingsDefault i) : SV_Target
2929{
30- float depth = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE (_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoTransformScreenSpaceTex (i.texcoord) ));
30+ float depth = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE (_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo ));
3131 half coc = (depth - _Distance) * _LensCoeff / max (depth, 1e-5 );
3232 return saturate (coc * 0.5 * _RcpMaxCoC + 0.5 );
3333}
@@ -71,7 +71,7 @@ half4 FragTempFilter(VaryingsDefault i) : SV_Target
7171
7272 // Neighborhood clamping
7373 half cocMin = closest.z;
74- half cocMax = max ( max ( max ( max ( coc0, coc1) , coc2), coc3) , coc4); // TODO: Switch to Max3
74+ half cocMax = Max3 ( Max3 ( coc0, coc1, coc2), coc3, coc4);
7575 cocHis = clamp (cocHis, cocMin, cocMax);
7676
7777 // Blend with the history
@@ -84,18 +84,17 @@ half4 FragPrefilter(VaryingsDefault i) : SV_Target
8484#if UNITY_GATHER_SUPPORTED
8585
8686 // Sample source colors
87- i.texcoord = UnityStereoTransformScreenSpaceTex (i.texcoord);
88- half4 c_r = GATHER_RED_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
89- half4 c_g = GATHER_GREEN_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
90- half4 c_b = GATHER_BLUE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
87+ half4 c_r = GATHER_RED_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoordStereo);
88+ half4 c_g = GATHER_GREEN_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoordStereo);
89+ half4 c_b = GATHER_BLUE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoordStereo);
9190
9291 half3 c0 = half3 (c_r.x, c_g.x, c_b.x);
9392 half3 c1 = half3 (c_r.y, c_g.y, c_b.y);
9493 half3 c2 = half3 (c_r.z, c_g.z, c_b.z);
9594 half3 c3 = half3 (c_r.w, c_g.w, c_b.w);
9695
9796 // Sample CoCs
98- half4 cocs = GATHER_TEXTURE2D (_CoCTex, sampler_CoCTex, i.texcoord ) * 2.0 - 1.0 ;
97+ half4 cocs = GATHER_TEXTURE2D (_CoCTex, sampler_CoCTex, i.texcoordStereo ) * 2.0 - 1.0 ;
9998 half coc0 = cocs.x;
10099 half coc1 = cocs.y;
101100 half coc2 = cocs.z;
@@ -151,7 +150,7 @@ half4 FragPrefilter(VaryingsDefault i) : SV_Target
151150// Bokeh filter with disk-shaped kernels
152151half4 FragBlur (VaryingsDefault i) : SV_Target
153152{
154- half4 samp0 = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, UnityStereoTransformScreenSpaceTex (i.texcoord) );
153+ half4 samp0 = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoordStereo );
155154
156155 half4 bgAcc = 0.0 ; // Background: far field bokeh
157156 half4 fgAcc = 0.0 ; // Foreground: near field bokeh
@@ -218,15 +217,14 @@ half4 FragPostBlur(VaryingsDefault i) : SV_Target
218217// Combine with source
219218half4 FragCombine (VaryingsDefault i) : SV_Target
220219{
221- i.texcoord = UnityStereoTransformScreenSpaceTex (i.texcoord);
222- half4 dof = SAMPLE_TEXTURE2D (_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoord);
223- half coc = SAMPLE_TEXTURE2D (_CoCTex, sampler_CoCTex, i.texcoord).r;
220+ half4 dof = SAMPLE_TEXTURE2D (_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoordStereo);
221+ half coc = SAMPLE_TEXTURE2D (_CoCTex, sampler_CoCTex, i.texcoordStereo).r;
224222 coc = (coc - 0.5 ) * 2.0 * _MaxCoC;
225223
226224 // Convert CoC to far field alpha value.
227225 float ffa = smoothstep (_MainTex_TexelSize.y * 2.0 , _MainTex_TexelSize.y * 4.0 , coc);
228226
229- half4 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord );
227+ half4 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoordStereo );
230228
231229#if defined (UNITY_COLORSPACE_GAMMA)
232230 color = SRGBToLinear (color);
@@ -247,12 +245,11 @@ half4 FragCombine(VaryingsDefault i) : SV_Target
247245// Debug overlay
248246half4 FragDebugOverlay (VaryingsDefault i) : SV_Target
249247{
250- i.texcoord = UnityStereoTransformScreenSpaceTex (i.texcoord);
251- half3 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord).rgb;
248+ half3 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoordStereo).rgb;
252249
253250 // Calculate the radiuses of CoC.
254- half4 src = SAMPLE_TEXTURE2D (_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoord );
255- float depth = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE (_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord ));
251+ half4 src = SAMPLE_TEXTURE2D (_DepthOfFieldTex, sampler_DepthOfFieldTex, i.texcoordStereo );
252+ float depth = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE (_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo ));
256253 float coc = (depth - _Distance) * _LensCoeff / depth;
257254 coc *= 80 ;
258255
0 commit comments