質問編集履歴
1
自己解決
title
CHANGED
File without changes
|
body
CHANGED
@@ -73,4 +73,75 @@
|
|
73
73
|
Fallback "Diffuse"
|
74
74
|
}
|
75
75
|
|
76
|
+
```
|
77
|
+
|
78
|
+
【追記】
|
79
|
+
閲覧してくださった方ありがとうございます。
|
80
|
+
こちらを参考に自分で作ってみました。[リンク内容](https://forum.unity.com/threads/how-add-support-to-alpha-on-this-shader.494460/)
|
81
|
+
・PNGテクスチャのアルファ有効
|
82
|
+
・前後関係の正しい半透明処理有効
|
83
|
+
```
|
84
|
+
Shader "ToonLitRemake" {
|
85
|
+
|
86
|
+
Properties {
|
87
|
+
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
|
88
|
+
_MainTex ("Alpha Blended (RGBA) ", 2D) = "white" {}
|
89
|
+
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
|
90
|
+
}
|
91
|
+
|
92
|
+
SubShader {
|
93
|
+
Tags {"Queue"="Transparent" "RenderType"="Transparent"}
|
94
|
+
Blend SrcAlpha OneMinusSrcAlpha
|
95
|
+
LOD 200
|
96
|
+
|
97
|
+
Pass{
|
98
|
+
ZWrite ON
|
99
|
+
ColorMask 0
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
CGPROGRAM
|
105
|
+
#pragma surface surf ToonRamp alpha:fade
|
106
|
+
|
107
|
+
sampler2D _Ramp;
|
108
|
+
|
109
|
+
// custom lighting function that uses a texture ramp based
|
110
|
+
// on angle between light direction and normal
|
111
|
+
#pragma lighting ToonRamp exclude_path:prepass
|
112
|
+
inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
|
113
|
+
{
|
114
|
+
#ifndef USING_DIRECTIONAL_LIGHT
|
115
|
+
lightDir = normalize(lightDir);
|
116
|
+
#endif
|
117
|
+
|
118
|
+
half d = dot (s.Normal, lightDir)*0.5 + 0.5;
|
119
|
+
half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
|
120
|
+
|
121
|
+
half4 c;
|
122
|
+
c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
|
123
|
+
c.a = s.Alpha;
|
124
|
+
return c;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
sampler2D _MainTex;
|
129
|
+
float4 _Color;
|
130
|
+
|
131
|
+
struct Input {
|
132
|
+
float2 uv_MainTex : TEXCOORD0;
|
133
|
+
};
|
134
|
+
|
135
|
+
void surf (Input IN, inout SurfaceOutput o) {
|
136
|
+
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
137
|
+
o.Albedo = c.rgb;
|
138
|
+
o.Alpha = c.a;
|
139
|
+
}
|
140
|
+
ENDCG
|
141
|
+
|
142
|
+
}
|
143
|
+
|
144
|
+
Fallback "Diffuse"
|
145
|
+
}
|
146
|
+
|
76
147
|
```
|