首页 > 代码库 > NGUI 可裁剪的灰度Shader
NGUI 可裁剪的灰度Shader
1 Shader "Custom/Unlit - Transparent Colored Grayed (SoftClip)" 2 { 3 Properties 4 { 5 _MainTex ("Base (RGB)", 2D) = "white" {} 6 } 7 8 SubShader { 9 LOD 20010 11 Tags12 {13 "Queue" = "Transparent"14 "IgnoreProjector" = "True"15 "RenderType" = "Transparent"16 }17 18 pass19 {20 Cull Off21 Lighting Off22 ZWrite Off23 24 Offset -1, -125 Fog 26 { 27 Mode Off 28 }29 ColorMask RGB30 AlphaTest Greater .0131 Blend SrcAlpha OneMinusSrcAlpha32 ColorMaterial AmbientAndDiffuse33 34 CGPROGRAM35 #pragma vertex vert36 #pragma fragment frag37 #include "UnityCG.cginc"38 39 sampler2D _MainTex;40 float4 _MainTex_ST;41 float2 _ClipSharpness = float2(20.0, 20.0);42 43 struct v2f44 {45 float4 vertex : POSITION;46 float4 pos : SV_POSITION;47 float2 uv : TEXCOORD0;48 float2 worldPos : TEXCOORD1;49 };50 51 v2f vert (appdata_base v)52 {53 v2f o;54 o.pos = mul (UNITY_MATRIX_MVP, v.vertex);55 o.uv = v.texcoord;56 o.worldPos = TRANSFORM_TEX(v.vertex.xy, _MainTex);57 return o;58 };59 60 half4 frag (v2f i) : COLOR61 {62 float2 factor = (float2(1.0, 1.0) - abs(i.worldPos)) * _ClipSharpness;63 half4 texcol = tex2D (_MainTex, i.uv);64 texcol.rgb = (texcol.r + texcol.g + texcol.b) / 3;65 texcol.a *= clamp( min(factor.x, factor.y), 0.0, 1.0);66 return texcol;67 };68 ENDCG69 }70 } 71 FallBack "Diffuse"72 }
NGUI 可裁剪的灰度Shader
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。