ShanDongVirtualPowerPlant/u3d-ShanDongVirtualPowerPlant/Assets/Adam/Shader/BorderCircle.shader

64 lines
1.6 KiB
Plaintext

Shader "Umawerse/BorderCircle"
{
Properties
{
_Color("Color",Color)=(0.5,0.5,0.5,1)
_Thickness("Thickness",Range(0,1)) = 0.1
_Border("Border",Color)=(1,1,1,1)
[Enum(UnityEngine.Rendering.CompareFunction)]_ZTest("ZTest",int) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Overlay" "PreviewType"="Plane"}
ZTest[_ZTest]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
fixed4 _Color;
fixed _Thickness;
fixed4 _Border;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = _Color;
const fixed r = 0.5;
const fixed ir = r*(1-_Thickness);
const fixed x = i.uv.x - r;
const fixed y = i.uv.y - r;
if(x*x+y*y>ir*ir) col = _Border;
clip(r*r-x*x-y*y);
return col;
}
ENDCG
}
}
}