-
Notifications
You must be signed in to change notification settings - Fork 66
/
UniformOutline.shader
80 lines (63 loc) · 1.24 KB
/
UniformOutline.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Shader "Outlined/Uniform"
{
Properties
{
_Color("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Texture", 2D) = "white" {}
_OutlineColor ("Outline color", Color) = (0,0,0,1)
_OutlineWidth ("Outlines width", Range (0.0, 2.0)) = 1.1
}
CGINCLUDE
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 pos : POSITION;
};
uniform float _OutlineWidth;
uniform float4 _OutlineColor;
uniform sampler2D _MainTex;
uniform float4 _Color;
ENDCG
SubShader
{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" }
Pass //Outline
{
ZWrite Off
Cull Back
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
v2f vert(appdata v)
{
appdata original = v;
v.vertex.xyz += _OutlineWidth * normalize(v.vertex.xyz);
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
half4 frag(v2f i) : COLOR
{
return _OutlineColor;
}
ENDCG
}
Tags{ "Queue" = "Geometry"}
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Diffuse"
}