
实现简易的水墨风效果大致分为三部分:
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

该文详细介绍了如何在Unity中创建简易的水墨风效果,包括将RGB贴图转化为灰度图,使用不同的图层混合模式结合水墨笔触贴图,以及应用菲涅尔效果进行描边处理。文章提供了具体的HLSL代码示例,展示了如何通过Shader实现这一艺术风格。

7988

被折叠的 条评论
为什么被折叠?



