zoukankan      html  css  js  c++  java
  • 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 200
    10         
    11         Tags
    12         {
    13             "Queue" = "Transparent"
    14             "IgnoreProjector" = "True"
    15             "RenderType" = "Transparent"
    16         }
    17         
    18         pass
    19         {
    20             Cull Off
    21             Lighting Off
    22             ZWrite Off
    23             
    24             Offset -1, -1
    25             Fog 
    26             { 
    27                 Mode Off 
    28             }
    29             ColorMask RGB
    30             AlphaTest Greater .01
    31             Blend SrcAlpha OneMinusSrcAlpha
    32             ColorMaterial AmbientAndDiffuse
    33             
    34             CGPROGRAM
    35             #pragma vertex vert
    36             #pragma fragment frag
    37             #include "UnityCG.cginc"
    38             
    39             sampler2D _MainTex;
    40             float4 _MainTex_ST;
    41             float2 _ClipSharpness = float2(20.0, 20.0);
    42             
    43             struct v2f
    44             {
    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) : COLOR
    61             {
    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             ENDCG
    69         }
    70     } 
    71     FallBack "Diffuse"
    72 }
  • 相关阅读:
    进度条加载后显示页面
    解决跨域问题
    js下IE和FF的一些兼容写法总结
    linux
    linux 批量替换文件内容
    DVWA-1.9之fileupload
    python库安装失败的解决方法
    python程序打包
    CF 1133C Balanced Team
    CF 1133B Preparation for International Women's Day
  • 原文地址:https://www.cnblogs.com/dabiaoge/p/4202236.html
Copyright © 2011-2022 走看看