11Shader "Hidden/PostProcessing/Copy"
22{
3- Properties
4- {
5- _MainTex ( "" , 2D ) = "white" {}
6- }
7-
83 HLSLINCLUDE
94
105 #include "../StdLib.hlsl"
116
12- struct AttributesClassic
13- {
14- float4 vertex : POSITION ;
15- float2 texcoord : TEXCOORD0 ;
16- };
17-
187 TEXTURE2D_SAMPLER2D (_MainTex, sampler_MainTex);
19- float4 _MainTex_ST;
20-
21- VaryingsDefault VertClassic (AttributesClassic v)
22- {
23- VaryingsDefault o;
24- o.vertex = float4 (v.vertex.xy * 2.0 - 1.0 , 0.0 , 1.0 );
25- o.texcoord = v.texcoord * _MainTex_ST.xy + _MainTex_ST.zw; // We need this for VR
26-
27- #if UNITY_UV_STARTS_AT_TOP
28- o.texcoord = o.texcoord * float2 (1.0 , -1.0 ) + float2 (0.0 , 1.0 );
29- #endif
30-
31- return o;
32- }
338
349 float4 Frag (VaryingsDefault i) : SV_Target
3510 {
3611 float4 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
3712 return color;
3813 }
3914
40- float4 FragKillNaN (VaryingsDefault i) : SV_Target
41- {
42- float4 color = SAMPLE_TEXTURE2D (_MainTex, sampler_MainTex, i.texcoord);
43-
44- #if !SHADER_API_GLES
45- if (any (isnan (color)) || any (isinf (color)))
46- {
47- color = (0.0 ).xxxx;
48- }
49- #endif
50-
51- return color;
52- }
53-
5415 ENDHLSL
5516
5617 SubShader
@@ -67,38 +28,5 @@ Shader "Hidden/PostProcessing/Copy"
6728
6829 ENDHLSL
6930 }
70-
71- // 1 - Fullscreen triangle copy + NaN killer
72- Pass
73- {
74- HLSLPROGRAM
75-
76- #pragma vertex VertDefault
77- #pragma fragment FragKillNaN
78-
79- ENDHLSL
80- }
81-
82- // 2 - Classic copy
83- Pass
84- {
85- HLSLPROGRAM
86-
87- #pragma vertex VertClassic
88- #pragma fragment Frag
89-
90- ENDHLSL
91- }
92-
93- // 3 - Classic copy + NaN killer
94- Pass
95- {
96- HLSLPROGRAM
97-
98- #pragma vertex VertClassic
99- #pragma fragment FragKillNaN
100-
101- ENDHLSL
102- }
10331 }
10432}
0 commit comments