@@ -5,24 +5,18 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
55 #include "../StdLib.hlsl"
66 #include "Fog.hlsl"
77
8+ TEXTURE2D_SAMPLER2D (_CameraDepthTexture, sampler_CameraDepthTexture);
89 TEXTURE2D_SAMPLER2D (_MSVOcclusionTexture, sampler_MSVOcclusionTexture);
910 float3 _AOColor;
1011
11- // Full screen triangle with procedural draw
12- // This can't be used when the destination can be the back buffer because
13- // this doesn't support the situations that requires vertical flipping.
14- VaryingsDefault VertProcedural (uint vid : SV_VertexID )
12+ VaryingsDefault Vert (AttributesDefault v)
1513 {
16- float x = vid == 1 ? 2 : 0 ;
17- float y = vid > 1 ? 2 : 0 ;
18-
1914 VaryingsDefault o;
20- o.vertex = float4 (x * 2.0 - 1.0 , 1.0 - y * 2.0 , 0.0 , 1.0 );
15+ o.vertex = float4 (v.vertex.xy, 0.0 , 1.0 );
16+ o.texcoord = TransformTriangleVertexToUV (v.vertex.xy);
2117
2218 #if UNITY_UV_STARTS_AT_TOP
23- o.texcoord = float2 (x, y);
24- #else
25- o.texcoord = float2 (x, 1.0 - y);
19+ o.texcoord = o.texcoord * float2 (1.0 , -1.0 ) + float2 (0.0 , 1.0 );
2620 #endif
2721
2822 o.texcoord = TransformStereoScreenSpaceTex (o.texcoord, 1 );
@@ -40,11 +34,9 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
4034 {
4135 HLSLPROGRAM
4236
43- #pragma vertex VertProcedural
37+ #pragma vertex Vert
4438 #pragma fragment Frag
4539
46- TEXTURE2D_SAMPLER2D (_CameraDepthTexture, sampler_CameraDepthTexture);
47-
4840 float4 Frag (VaryingsDefault i) : SV_Target
4941 {
5042 return SAMPLE_DEPTH_TEXTURE (_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord);
@@ -60,10 +52,9 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
6052
6153 HLSLPROGRAM
6254
63- #pragma vertex VertProcedural
55+ #pragma vertex Vert
6456 #pragma fragment Frag
6557
66-
6758 struct Output
6859 {
6960 float4 gbuffer0 : SV_Target0 ;
@@ -85,15 +76,14 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
8576 // 2 - Composite to the frame buffer
8677 Pass
8778 {
79+ Blend Zero OneMinusSrcColor , Zero OneMinusSrcAlpha
80+
8881 HLSLPROGRAM
8982
9083 #pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
91- #pragma vertex VertDefault
84+ #pragma vertex Vert
9285 #pragma fragment Frag
9386
94- TEXTURE2D_SAMPLER2D (_MainTex, sampler_MainTex);
95- TEXTURE2D_SAMPLER2D (_CameraDepthTexture, sampler_CameraDepthTexture);
96-
9787 float4 Frag (VaryingsDefault i) : SV_Target
9888 {
9989 float2 texcoord = TransformStereoScreenSpaceTex (i.texcoord, 1 );
@@ -106,9 +96,7 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
10696 ao *= ComputeFog (d);
10797 #endif
10898
109- half4 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, texcoord);
110- color.rgb *= 1.0 - ao * _AOColor;
111- return color;
99+ return float4 (ao * _AOColor, 0.0 );
112100 }
113101
114102 ENDHLSL
0 commit comments