Skip to content

Commit f0dac0a

Browse files
committed
+ToonIce Shader
1 parent 8ecf173 commit f0dac0a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Shaders/Effects/ToonIce.shader

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Shader "Toon/Ice" {
2+
Properties {
3+
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
4+
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
5+
_BottomColor("Bottom Color", Color) = (0.23,0,0.95,1)
6+
_RimBrightness("Rim Brightness", Range(3,4)) = 3.5
7+
_Alpha("Transparency", Range(0,1)) = 0.5
8+
}
9+
10+
SubShader {
11+
12+
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
13+
LOD 200
14+
Blend SrcAlpha OneMinusSrcAlpha
15+
CGPROGRAM
16+
//#pragma surface surf ToonRamp
17+
#pragma surface surf Lambert alpha
18+
19+
sampler2D _Ramp;
20+
21+
// custom lighting function that uses a texture ramp based
22+
// on angle between light direction and normal
23+
#pragma lighting ToonRamp exclude_path:prepass
24+
inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
25+
{
26+
#ifndef USING_DIRECTIONAL_LIGHT
27+
lightDir = normalize(lightDir);
28+
#endif
29+
30+
half d = dot (s.Normal, lightDir)*0.5 + 0.5;
31+
half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
32+
33+
half4 c;
34+
c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
35+
c.a = 0;
36+
return c;
37+
}
38+
39+
40+
float4 _Color;
41+
float4 _BottomColor;
42+
float _RimBrightness;
43+
float _Alpha;
44+
struct Input {
45+
float3 worldPos;
46+
float3 viewDir;
47+
};
48+
49+
void surf (Input IN, inout SurfaceOutput o) {
50+
float3 localPos = saturate(IN.worldPos - mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz);
51+
float softRim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
52+
float hardRim = round(softRim);
53+
o.Emission = _Color* lerp(hardRim, softRim, localPos.y) * (_RimBrightness*localPos.y);
54+
float InnerRim = 1.5 + saturate(dot(normalize(IN.viewDir), o.Normal));
55+
o.Albedo = _Color*pow(InnerRim, 0.7) * lerp(_BottomColor, _Color, localPos.y);
56+
o.Alpha = _Alpha;
57+
}
58+
ENDCG
59+
60+
}
61+
62+
Fallback "Diffuse"
63+
}

0 commit comments

Comments
 (0)