unity-shader-ColorMask

通道遮罩 ColorMask,原文链接:http://blog.csdn.net/LIQIANGEASTSUN/article/details/44962107


ColorMask可以让我们制定渲染结果的输出通道,而不是通常情况下的RGBA这4个通道全部写入。可选参数是 RGBA 的任意组合以及 0, 这将意味着不会写入到任何通道,可以用来单独做一次Z测试,而不将结果写入颜色通道

使用如下

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
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"
}

这里写图片描述

这里写图片描述

这里写图片描述