-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuillShader.shader
More file actions
92 lines (73 loc) · 2.38 KB
/
QuillShader.shader
File metadata and controls
92 lines (73 loc) · 2.38 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
Shader "Unlit/Quill Shader"
{
Properties
{
[Toggle] _EnableTransparency("Enable Transparency", Int) = 1
[Enum(Yes,0,No,2)] _Cull("Double Sided", Int) = 2
[Toggle] _EnableFog("Enable Fog", Int) = 0
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry" }
LOD 100
Blend Off
Cull[_Cull]
ZWrite On
ZTest On
Pass
{
AlphaToMask[_EnableTransparency]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma shader_feature _ENABLEFOG_ON
#pragma shader_feature _ENABLETRANSPARENCY_ON
#include "UnityCG.cginc"
struct inVertex
{
float4 vertex : POSITION;
float4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
#ifdef _ENABLEFOG_ON
UNITY_FOG_COORDS(1)
#endif
#ifdef _ENABLETRANSPARENCY_ON
float4 screenPos : TEXCOORD2;
#endif
float4 color : COLOR;
};
v2f vert(inVertex v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
#ifdef _ENABLEFOG_ON
UNITY_TRANSFER_FOG(o, o.vertex);
#endif
#ifdef _ENABLETRANSPARENCY_ON
o.screenPos = ComputeScreenPos(o.vertex);
#endif
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float4 col = i.color;
#ifdef _ENABLEFOG_ON
UNITY_APPLY_FOG(i.fogCoord, col);
#endif
#ifdef _ENABLETRANSPARENCY_ON
float2 pos = _ScreenParams.xy * i.screenPos.xy / i.screenPos.w;
const int MSAASampleCount = 8;
float ran = frac(52.9829189*frac(dot(pos, float2(0.06711056,0.00583715))));
col.a = clamp(col.a + 0.99*(ran-0.5)/float(MSAASampleCount), 0.0, 1.0);
#endif
return col;
}
ENDCG
}
}
}