Sharder通道遮罩ColorMask详解
发表于2018-05-18
ColorMask可以让我们制定渲染结果的输出通道,而不是通常情况下的RGBA这4个通道全部写入。可选参数是 RGBA 的任意组合以及 0, 这将意味着不会写入到任何通道,可以用来单独做一次Z测试,而不将结果写入颜色通道。
使用如下
Shader "Custom/PassFive" { Properties { //定义一个贴图 _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags {"RenderType" = "Opaque" "IGNOREPROJECTOR" = "TRUE" "QUEUE" = "Transparent"} LOD 200 Pass { //AlphaTest Greater 0.6 //AlphaTest Less 0.5 //AlphaTest Greater 0.4 //AlphaTest Less 0.9 Blend SrcAlpha One //Blend SrcColor OneMinusSrcColor //BlendOp RevSub //ColorMask RG ColorMask RB // 通过绑定固定通道来使用定点色 BindChannels { Bind "Vertex", vertex // 绑定定点 Bind "Normal", normal Bind "Color", color Bind "Texcoord", texcoord0 Bind "Texcoord", texcoord1 } //给材质设置 贴图 SetTexture [_MainTex] { Combine texture * primary double } } } FallBack "Diffuse" }



如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引