forked from ZGeng/DeepSnowFootprint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSprites-Distance.shader
84 lines (69 loc) · 1.41 KB
/
Sprites-Distance.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
81
82
83
84
Shader "Sprites/Distance"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
//_Color ("Tint", Color) = (1,1,1,1)
//[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite On //open ZWreite
ZTest LEqual
//Blend OneOne
Blend One Zero
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
//#pragma shader_feature ETC1_EXTERNAL_ALPHA
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct fout
{
fixed4 color : SV_Target;
float depth : SV_Depth;
};
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color;
return OUT;
}
fout frag(v2f IN)
{
fout OUT;
OUT.color.rgb = IN.color.rgb;////r,g is the relative center position b is angle
float dist = distance(IN.texcoord, float2(.5f, .5f))*2.0f;
OUT.color.a = IN.color.a;
OUT.depth = 1.0f-dist;
return OUT;
}
ENDCG
}
}
}