質問編集履歴
1
自己解決
test
CHANGED
File without changes
|
test
CHANGED
@@ -149,3 +149,145 @@
|
|
149
149
|
|
150
150
|
|
151
151
|
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
【追記】
|
156
|
+
|
157
|
+
閲覧してくださった方ありがとうございます。
|
158
|
+
|
159
|
+
こちらを参考に自分で作ってみました。[リンク内容](https://forum.unity.com/threads/how-add-support-to-alpha-on-this-shader.494460/)
|
160
|
+
|
161
|
+
・PNGテクスチャのアルファ有効
|
162
|
+
|
163
|
+
・前後関係の正しい半透明処理有効
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
Shader "ToonLitRemake" {
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
Properties {
|
172
|
+
|
173
|
+
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
|
174
|
+
|
175
|
+
_MainTex ("Alpha Blended (RGBA) ", 2D) = "white" {}
|
176
|
+
|
177
|
+
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
SubShader {
|
184
|
+
|
185
|
+
Tags {"Queue"="Transparent" "RenderType"="Transparent"}
|
186
|
+
|
187
|
+
Blend SrcAlpha OneMinusSrcAlpha
|
188
|
+
|
189
|
+
LOD 200
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
Pass{
|
194
|
+
|
195
|
+
ZWrite ON
|
196
|
+
|
197
|
+
ColorMask 0
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
CGPROGRAM
|
208
|
+
|
209
|
+
#pragma surface surf ToonRamp alpha:fade
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
sampler2D _Ramp;
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
// custom lighting function that uses a texture ramp based
|
218
|
+
|
219
|
+
// on angle between light direction and normal
|
220
|
+
|
221
|
+
#pragma lighting ToonRamp exclude_path:prepass
|
222
|
+
|
223
|
+
inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
|
224
|
+
|
225
|
+
{
|
226
|
+
|
227
|
+
#ifndef USING_DIRECTIONAL_LIGHT
|
228
|
+
|
229
|
+
lightDir = normalize(lightDir);
|
230
|
+
|
231
|
+
#endif
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
half d = dot (s.Normal, lightDir)*0.5 + 0.5;
|
236
|
+
|
237
|
+
half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
half4 c;
|
242
|
+
|
243
|
+
c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
|
244
|
+
|
245
|
+
c.a = s.Alpha;
|
246
|
+
|
247
|
+
return c;
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
sampler2D _MainTex;
|
256
|
+
|
257
|
+
float4 _Color;
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
struct Input {
|
262
|
+
|
263
|
+
float2 uv_MainTex : TEXCOORD0;
|
264
|
+
|
265
|
+
};
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
void surf (Input IN, inout SurfaceOutput o) {
|
270
|
+
|
271
|
+
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
272
|
+
|
273
|
+
o.Albedo = c.rgb;
|
274
|
+
|
275
|
+
o.Alpha = c.a;
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
ENDCG
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
Fallback "Diffuse"
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
```
|