summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/UMotion/UMotionEditor/Shaders/UnlitLine.shader
blob: 6c78911660a3ae4e82236f724ca5f9b3c57c9b8b (plain)
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
Shader "UMotion Editor/Unlit Line"
{ 
    Properties 
    {
		_Color("Line Color (RGB) Trans (A)", color) = (0, 0, 0, 1)
		_Thickness("Line Thikness", Range(0, 4)) = 0.9
    }

    SubShader 
    {
		Tags {"Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" }
        LOD 100

        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha
		Cull Off

		Pass
	    {
            CGPROGRAM
		    #pragma vertex vert
	    	#pragma fragment frag
			#pragma target 3.0

			#include "UnityCG.cginc"

			fixed4 _Color;
			half _Thickness;

			struct vInput
			{
				float4 vertex : POSITION;
				half4 texcoord : TEXCOORD0;
			};

			struct vOutput
			{
				float4 pos : SV_POSITION;
				float uv_y : TEXCOORD0;
			};

			vOutput vert(vInput i)
			{
				vOutput o;

				o.pos = UnityObjectToClipPos(i.vertex);
				o.uv_y = i.texcoord.y;

				return o;
			}

			fixed4 frag(vOutput i) : SV_Target 
			{
				half width = abs(ddx(i.uv_y)) + abs(ddy(i.uv_y));
				half alpha = smoothstep(0, width * _Thickness, i.uv_y);

				return fixed4(_Color.x, _Color.y, _Color.z, 1 - alpha);
			}

			ENDCG
    	} //Pass
    } //SubShader
} //Shader