質問するログイン新規登録

回答編集履歴

1

スクリプトの書換

2019/04/19 08:13

投稿

退会済みユーザー
answer CHANGED
@@ -2,59 +2,67 @@
2
2
  結果として、最初に生成していたシェーダーの上に描画されました。
3
3
 
4
4
  ```ShaderLab
5
- Shader "Custom/NewSurfaceShader"
5
+ Shader "Unlit/ZWriteShader"
6
6
  {
7
7
  Properties
8
8
  {
9
- _Color ("Color", Color) = (1,1,1,1)
10
- _MainTex ("Albedo (RGB)", 2D) = "white" {}
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
- ZTest Always
14
+ ZTest Always
18
- LOD 200
15
+ LOD 100
19
16
 
20
- CGPROGRAM
17
+ ZWrite Off
21
- // Physically based Standard lighting model, and enable shadows on all light types
22
- #pragma surface surf Standard fullforwardshadows
18
+ Blend SrcAlpha OneMinusSrcAlpha
23
19
 
20
+ Pass
21
+ {
24
- // Use shader model 3.0 target, to get nicer looking lighting
22
+ CGPROGRAM
25
- #pragma target 3.0
23
+ #pragma vertex vert
24
+ #pragma fragment frag
25
+ // make fog work
26
+ #pragma multi_compile_fog
26
27
 
27
- sampler2D _MainTex;
28
+ #include "UnityCG.cginc"
28
29
 
29
- struct Input
30
+ struct appdata
30
- {
31
+ {
32
+ float4 vertex : POSITION;
31
- float2 uv_MainTex;
33
+ float2 uv : TEXCOORD0;
32
- };
34
+ };
33
35
 
36
+ struct v2f
37
+ {
38
+ float2 uv : TEXCOORD0;
34
- half _Glossiness;
39
+ UNITY_FOG_COORDS(1)
35
- half _Metallic;
36
- fixed4 _Color;
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
- // #pragma instancing_options assumeuniformscaling
43
+ sampler2D _MainTex;
41
- UNITY_INSTANCING_BUFFER_START(Props)
44
+ float4 _MainTex_ST;
42
- // put more per-instance properties here
43
- UNITY_INSTANCING_BUFFER_END(Props)
44
45
 
45
- void surf (Input IN, inout SurfaceOutputStandard o)
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
- // Albedo comes from a texture tinted by color
57
+ // sample the texture
48
- fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
58
+ fixed4 col = tex2D(_MainTex, i.uv);
49
- o.Albedo = c.rgb;
50
- // Metallic and smoothness come from slider variables
51
- o.Metallic = _Metallic;
59
+ // apply fog
52
- o.Smoothness = _Glossiness;
60
+ UNITY_APPLY_FOG(i.fogCoord, col);
53
- o.Alpha = c.a;
61
+ return col;
62
+ }
63
+ ENDCG
54
64
  }
55
- ENDCG
56
65
  }
57
- FallBack "Diffuse"
58
66
  }
59
67
 
60
68
  ```