forked from UnityCommunity/UnityLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add LineRenderer_ClipStartEnd.shader
- Loading branch information
1 parent
2c971b1
commit e12d361
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
Assets/Shaders/2D/LineRenderer/LineRenderer_ClipStartEnd.shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Shader "UnityLibrary/LineRenderer/ClipStartEnd" | ||
{ | ||
Properties | ||
{ | ||
_MainTex ("Texture", 2D) = "white" {} | ||
_Start ("Start", Range (0.0,1.0)) = 0.25 | ||
_End ("End", Range (0.0,1.0)) = 0.75 | ||
} | ||
|
||
SubShader | ||
{ | ||
Tags { "RenderType"="Opaque" } | ||
LOD 100 | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata | ||
{ | ||
float4 vertex : POSITION; | ||
float2 uv : TEXCOORD0; | ||
float4 color : COLOR; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float2 uv : TEXCOORD0; | ||
float4 vertex : SV_POSITION; | ||
float4 color : COLOR; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
float4 _MainTex_ST; | ||
float _Start; | ||
float _End; | ||
|
||
|
||
v2f vert (appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | ||
o.color = v.color; | ||
return o; | ||
} | ||
|
||
fixed4 frag(v2f i) : SV_Target | ||
{ | ||
fixed4 col = tex2D(_MainTex, i.uv)*i.color; | ||
clip(-(i.uv.x <_Start || i.uv.x > _End)); | ||
// return fixed4(i.uv.x,0,0,0); // view UV x | ||
return col; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |