源自 Unlit-AlphaTest
唯一一个知识点就是clip了
Clip:Discards the current pixel if the specified value is less than zero.
clip
(col.a - _Cutoff);
这个就等价于
if(col.a-_Cutoff < 0) discard;
这个例子是clip(float a)那么大家有试过clip(float2 a) clip(float3 a) clip(float4 a)。
下面以clip(float4 a)为例,看一下返回值是什么
例子源码
clip
(_Color);
是的就是把_Color做参直传。
是的并没有效果。。。
要细看,人家说的是小于0,并不包括等于0的情况。
于是修改例子
float4
testValue = _Color*
2
-
1
;
clip
(testValue);
然后结果就很明显了,这里我就不帖图片了
任何一个通道小于0,都会被discard。
那么clip(float4 a)这个方法的定义是如何呢?
void clip(float4 x) { if (any(x < 0)) discard; }
不要问我any是什么意思,打死我都不会说的。
any:Determines if any components of the specified value are non-zero.True if any components of the x parameter are non-zero; otherwise, false.
与any对应的是all
以上都是微软说的。