Shader "Unlit/halfShader"
{
Properties
{
_Diffuse("Diffuse", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_StartCutoff("StartCutoff", Range(-1, 360)) = 0
_EndCutoff("EndCutoff", Range(-1, 360)) = 0
_Cutoff("Cutoff", Range(0.0, 1.0)) = 1
}
SubShader
{
//Tags { "RenderType"="Opaque" }
Tags { "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent"}
LOD 100
Pass
{
//Tags { "LightMode" = "ForwardBase"}
//ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
fixed4 _Diffuse;
float _StartCutoff;
float _EndCutoff;
float _Cutoff;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
float3 xyz :TEXCOORD1;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.xyz = v.vertex.xyz;
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
col = _Diffuse;
// apply fog
//UNITY_APPLY_FOG(i.fogCoord, col);
//float vy = acos(i.xyz.y / sqrt(i.xyz.x * i.xyz.x + i.xyz.y * i.xyz.y)) / 3.1415926 * 180;
float vx = acos(i.xyz.z / sqrt(i.xyz.x * i.xyz.x + i.xyz.z * i.xyz.z)) / 3.1415926 * 180;
if (vx >= _StartCutoff && vx <= _EndCutoff && _Cutoff < 1.0)
col.a = _Cutoff;
//clip(i.col.a - _Cutoff);
return col;
}
ENDCG
}
}
}
10-09