回答編集履歴
1
スクリプトの書換
answer
CHANGED
@@ -2,59 +2,67 @@
|
|
2
2
|
結果として、最初に生成していたシェーダーの上に描画されました。
|
3
3
|
|
4
4
|
```ShaderLab
|
5
|
-
Shader "
|
5
|
+
Shader "Unlit/ZWriteShader"
|
6
6
|
{
|
7
7
|
Properties
|
8
8
|
{
|
9
|
-
_Color ("Color", Color) = (1,1,1,1)
|
10
|
-
_MainTex ("
|
9
|
+
_MainTex ("Texture", 2D) = "white" {}
|
11
|
-
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
12
|
-
_Metallic ("Metallic", Range(0,1)) = 0.0
|
13
10
|
}
|
14
11
|
SubShader
|
15
12
|
{
|
16
13
|
Tags { "RenderType"="Opaque" "Queue"="Geometry+5" }
|
17
|
-
|
14
|
+
ZTest Always
|
18
|
-
LOD
|
15
|
+
LOD 100
|
19
16
|
|
20
|
-
|
17
|
+
ZWrite Off
|
21
|
-
// Physically based Standard lighting model, and enable shadows on all light types
|
22
|
-
|
18
|
+
Blend SrcAlpha OneMinusSrcAlpha
|
23
19
|
|
20
|
+
Pass
|
21
|
+
{
|
24
|
-
|
22
|
+
CGPROGRAM
|
25
|
-
|
23
|
+
#pragma vertex vert
|
24
|
+
#pragma fragment frag
|
25
|
+
// make fog work
|
26
|
+
#pragma multi_compile_fog
|
26
27
|
|
27
|
-
|
28
|
+
#include "UnityCG.cginc"
|
28
29
|
|
29
|
-
|
30
|
+
struct appdata
|
30
|
-
|
31
|
+
{
|
32
|
+
float4 vertex : POSITION;
|
31
|
-
|
33
|
+
float2 uv : TEXCOORD0;
|
32
|
-
|
34
|
+
};
|
33
35
|
|
36
|
+
struct v2f
|
37
|
+
{
|
38
|
+
float2 uv : TEXCOORD0;
|
34
|
-
|
39
|
+
UNITY_FOG_COORDS(1)
|
35
|
-
half _Metallic;
|
36
|
-
|
40
|
+
float4 vertex : SV_POSITION;
|
41
|
+
};
|
37
42
|
|
38
|
-
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
39
|
-
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
40
|
-
|
43
|
+
sampler2D _MainTex;
|
41
|
-
|
44
|
+
float4 _MainTex_ST;
|
42
|
-
// put more per-instance properties here
|
43
|
-
UNITY_INSTANCING_BUFFER_END(Props)
|
44
45
|
|
45
|
-
|
46
|
+
v2f vert (appdata v)
|
46
|
-
|
47
|
+
{
|
48
|
+
v2f o;
|
49
|
+
o.vertex = UnityObjectToClipPos(v.vertex);
|
50
|
+
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
51
|
+
UNITY_TRANSFER_FOG(o,o.vertex);
|
52
|
+
return o;
|
53
|
+
}
|
54
|
+
|
55
|
+
fixed4 frag (v2f i) : SV_Target
|
56
|
+
{
|
47
|
-
|
57
|
+
// sample the texture
|
48
|
-
|
58
|
+
fixed4 col = tex2D(_MainTex, i.uv);
|
49
|
-
o.Albedo = c.rgb;
|
50
|
-
// Metallic and smoothness come from slider variables
|
51
|
-
|
59
|
+
// apply fog
|
52
|
-
|
60
|
+
UNITY_APPLY_FOG(i.fogCoord, col);
|
53
|
-
|
61
|
+
return col;
|
62
|
+
}
|
63
|
+
ENDCG
|
54
64
|
}
|
55
|
-
ENDCG
|
56
65
|
}
|
57
|
-
FallBack "Diffuse"
|
58
66
|
}
|
59
67
|
|
60
68
|
```
|