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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| Shader "Custome/BlockOff" { Properties { [Header(The Blocked Part)] [Space(10)] _Color("X-Ray Color",Color) = (0,1,1,1) _Width("X-Ray Width",Range(1,2)) = 1 _Brightness("X-Ray Brightness",Range(0,2)) = 1
[Header(The Normal Part)] [Space(10)] _Albedo("Albedo",2D) = "white" {} [NoScaleOffset]_Specular("Specular(RGB-A)",2D) = "block"{} [NoScaleOffset]_Normal("Normal",2D) = "bump" {} [NoScaleOffset]_AO("AO",2D) = "white"{} } SubShader { Tags { "Queue"="Transparent" }
Pass { ZTest Greater ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc"
struct v2f { float4 vertexPos : SV_POSITION; float3 viewDir : TEXCOORD0; float3 worldNor : TEXCOORD1; };
fixed4 _Color; fixed _Width; half _Brightness;
v2f vert(appdata_base v) { v2f o; o.vertexPos = UnityObjectToClipPos(v.vertex); o.viewDir = normalize(WorldSpaceViewDir(v.vertex)); o.worldNor = UnityObjectToWorldNormal(v.normal);
return o; }
float4 frag(v2f i) :SV_Target{ half NDotV = saturate(dot(i.worldNor,i.viewDir)); NDotV = pow(1 - NDotV, _Width) * _Brightness;
fixed4 color; color.rgb = _Color.rgb; color.a = NDotV;
return color; } ENDCG }
CGPROGRAM #pragma surface surf StandardSpecular fullforwardshadows
struct Input { float2 uv_Albedo; };
sampler2D _Albedo; sampler2D _Specular; sampler2D _Normal; sampler2D _AO;
void surf(Input IN, inout SurfaceOutputStandardSpecular o) { fixed4 c = tex2D(_Albedo, IN.uv_Albedo); o.Albedo = c.rgb;
fixed4 specular = tex2D(_Specular, IN.uv_Albedo); o.Specular = specular.rgb; o.Smoothness = specular.a;
o.Normal = UnpackNormal(tex2D(_Normal, IN.uv_Albedo)); o.Occlusion = tex2D(_AO, IN.uv_Albedo); }
ENDCG } }
|