-
Notifications
You must be signed in to change notification settings - Fork 26
/
Silhouette.shader
70 lines (52 loc) · 1.3 KB
/
Silhouette.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
// This two-pass shader renders a silhouette on top of all other geometry when occluded.
Shader "Custom/Silhouette" {
Properties {
_MainTex("Main Texture", 2D) = "white" { }
_SilhouetteColor("Silhouette Color", Color) = (0.0, 0.0, 0.0, 1.0)
}
SubShader {
// Render queue +1 to render after all solid objects
Tags { "Queue" = "Geometry+1" "RenderType"="Opaque" }
Pass {
// Don't write to the depth buffer for the silhouette pass
ZWrite Off
ZTest Always
// First Pass: Silhouette
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 _SilhouetteColor;
struct vertInput {
float4 vertex:POSITION;
float3 normal:NORMAL;
};
struct fragInput {
float4 pos:SV_POSITION;
};
fragInput vert(vertInput i) {
fragInput o;
o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
return o;
}
float4 frag(fragInput i) : COLOR {
return _SilhouetteColor;
}
ENDCG
}
// Second Pass: Standard
CGPROGRAM
#pragma surface surf Lambert
#include "UnityCG.cginc"
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o) {
float4 col = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = col.rgb;
}
ENDCG
}
FallBack "Diffuse"
}