Skip to content

Commit e12d361

Browse files
authored
add LineRenderer_ClipStartEnd.shader
1 parent 2c971b1 commit e12d361

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Shader "UnityLibrary/LineRenderer/ClipStartEnd"
2+
{
3+
Properties
4+
{
5+
_MainTex ("Texture", 2D) = "white" {}
6+
_Start ("Start", Range (0.0,1.0)) = 0.25
7+
_End ("End", Range (0.0,1.0)) = 0.75
8+
}
9+
10+
SubShader
11+
{
12+
Tags { "RenderType"="Opaque" }
13+
LOD 100
14+
15+
Pass
16+
{
17+
CGPROGRAM
18+
#pragma vertex vert
19+
#pragma fragment frag
20+
21+
#include "UnityCG.cginc"
22+
23+
struct appdata
24+
{
25+
float4 vertex : POSITION;
26+
float2 uv : TEXCOORD0;
27+
float4 color : COLOR;
28+
};
29+
30+
struct v2f
31+
{
32+
float2 uv : TEXCOORD0;
33+
float4 vertex : SV_POSITION;
34+
float4 color : COLOR;
35+
};
36+
37+
sampler2D _MainTex;
38+
float4 _MainTex_ST;
39+
float _Start;
40+
float _End;
41+
42+
43+
v2f vert (appdata v)
44+
{
45+
v2f o;
46+
o.vertex = UnityObjectToClipPos(v.vertex);
47+
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
48+
o.color = v.color;
49+
return o;
50+
}
51+
52+
fixed4 frag(v2f i) : SV_Target
53+
{
54+
fixed4 col = tex2D(_MainTex, i.uv)*i.color;
55+
clip(-(i.uv.x <_Start || i.uv.x > _End));
56+
// return fixed4(i.uv.x,0,0,0); // view UV x
57+
return col;
58+
}
59+
ENDCG
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)