实现简易的水墨风效果大致分为三部分:
1.将原始的rgb贴图转化为灰度图
float4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
float texGrey = (baseMap.r + baseMap.g + baseMap.b) * 0.33;
texGrey = pow(texGrey, 0.3);
texGrey *= 1 - cos(texGrey * 3.14);
2.使用一张水墨笔触的贴图,同样转化为灰度图,并和原始贴图的灰度进行混合。
用枚举的方式设置不同的混合方式:
[Enum(Opacity, 1, Darken, 2, Lighten, 3, Multiply, 4, Screen, 5, Overlay, 6, SoftLight, 7)]
_BlendType ("Blend Type", Int) = 1
基于PS的图层叠加算法:
float blend;
if (_BlendType == 1)
blend = texGrey * 0.5 + brushGrey * 0.5;
else if (_BlendType == 2)
blend = texGrey < brushGrey ? texGrey : brushGrey;
else if (_BlendType == 3)
blend = texGrey > brushGrey ? texGrey : brushGrey;
else if (_