回答編集履歴

1

スクリプトの書換

2019/04/19 08:13

投稿

退会済みユーザー
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ```ShaderLab
8
8
 
9
- Shader "Custom/NewSurfaceShader"
9
+ Shader "Unlit/ZWriteShader"
10
10
 
11
11
  {
12
12
 
@@ -14,13 +14,7 @@
14
14
 
15
15
  {
16
16
 
17
- _Color ("Color", Color) = (1,1,1,1)
18
-
19
- _MainTex ("Albedo (RGB)", 2D) = "white" {}
17
+ _MainTex ("Texture", 2D) = "white" {}
20
-
21
- _Glossiness ("Smoothness", Range(0,1)) = 0.5
22
-
23
- _Metallic ("Metallic", Range(0,1)) = 0.0
24
18
 
25
19
  }
26
20
 
@@ -30,87 +24,109 @@
30
24
 
31
25
  Tags { "RenderType"="Opaque" "Queue"="Geometry+5" }
32
26
 
33
- ZTest Always
27
+ ZTest Always
34
28
 
35
- LOD 200
29
+ LOD 100
36
30
 
37
31
 
38
32
 
39
- CGPROGRAM
33
+ ZWrite Off
40
34
 
41
- // Physically based Standard lighting model, and enable shadows on all light types
42
-
43
- #pragma surface surf Standard fullforwardshadows
35
+ Blend SrcAlpha OneMinusSrcAlpha
44
36
 
45
37
 
46
38
 
47
- // Use shader model 3.0 target, to get nicer looking lighting
39
+ Pass
48
40
 
41
+ {
42
+
43
+ CGPROGRAM
44
+
49
- #pragma target 3.0
45
+ #pragma vertex vert
46
+
47
+ #pragma fragment frag
48
+
49
+ // make fog work
50
+
51
+ #pragma multi_compile_fog
50
52
 
51
53
 
52
54
 
53
- sampler2D _MainTex;
55
+ #include "UnityCG.cginc"
54
56
 
55
57
 
56
58
 
57
- struct Input
59
+ struct appdata
58
60
 
59
- {
61
+ {
60
62
 
61
- float2 uv_MainTex;
63
+ float4 vertex : POSITION;
62
64
 
65
+ float2 uv : TEXCOORD0;
66
+
63
- };
67
+ };
64
68
 
65
69
 
66
70
 
67
- half _Glossiness;
71
+ struct v2f
68
72
 
69
- half _Metallic;
73
+ {
70
74
 
71
- fixed4 _Color;
75
+ float2 uv : TEXCOORD0;
76
+
77
+ UNITY_FOG_COORDS(1)
78
+
79
+ float4 vertex : SV_POSITION;
80
+
81
+ };
72
82
 
73
83
 
74
84
 
75
- // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
85
+ sampler2D _MainTex;
76
86
 
77
- // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
78
-
79
- // #pragma instancing_options assumeuniformscaling
80
-
81
- UNITY_INSTANCING_BUFFER_START(Props)
87
+ float4 _MainTex_ST;
82
-
83
- // put more per-instance properties here
84
-
85
- UNITY_INSTANCING_BUFFER_END(Props)
86
88
 
87
89
 
88
90
 
89
- void surf (Input IN, inout SurfaceOutputStandard o)
91
+ v2f vert (appdata v)
90
92
 
91
- {
93
+ {
92
94
 
93
- // Albedo comes from a texture tinted by color
95
+ v2f o;
94
96
 
95
- fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
97
+ o.vertex = UnityObjectToClipPos(v.vertex);
96
98
 
97
- o.Albedo = c.rgb;
99
+ o.uv = TRANSFORM_TEX(v.uv, _MainTex);
98
100
 
99
- // Metallic and smoothness come from slider variables
101
+ UNITY_TRANSFER_FOG(o,o.vertex);
100
102
 
101
- o.Metallic = _Metallic;
103
+ return o;
102
104
 
103
- o.Smoothness = _Glossiness;
105
+ }
104
106
 
107
+
108
+
109
+ fixed4 frag (v2f i) : SV_Target
110
+
111
+ {
112
+
113
+ // sample the texture
114
+
115
+ fixed4 col = tex2D(_MainTex, i.uv);
116
+
117
+ // apply fog
118
+
119
+ UNITY_APPLY_FOG(i.fogCoord, col);
120
+
105
- o.Alpha = c.a;
121
+ return col;
122
+
123
+ }
124
+
125
+ ENDCG
106
126
 
107
127
  }
108
128
 
109
- ENDCG
110
-
111
129
  }
112
-
113
- FallBack "Diffuse"
114
130
 
115
131
  }
116
132