## 资料
- [ ] 游戏诞生之日09 - 美术篇 卡通渲染着色器 UTS2 https://zhuanlan.zhihu.com/p/137288013
- [ ] MMD联动Unity学习笔记 Vol.42 UTS2进阶(慎入长篇多图预警)https://www.bilibili.com/read/cv3347514
- [ ] 官方文档:https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project/blob/release/urp/2.3.0/Documentation~/index.md
- [ ] 官方文档——属性解释:https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project/blob/release/urp/2.3.0/Documentation~/Props_en.md

## 总览
没有后处理效果

两种着色方式:
DoubleShadeWithFeather:UTS/UniversalToon 的标准工作流程模式。允许 2 种阴影颜色(双阴影颜色)和颜色之间的渐变(羽化)。
ShadingGradeMap:更高级的工作流程模式。除了 DoubleShadeWithFeather 功能之外,此着色器还可以保存称为 ShadingGradeMap 的特殊贴图。

- UniversalToonInput.hlsl:定义各种变量与资料,实现采样AO贴图`SampleOcclusion()`与初始化Lit表面数据`InitializeStandardLitSurfaceData()`
- UniversalToonHead.hlsl:定义了一些宏与函数,雾、坐标转换、线性空间与GammaSpace转换相关。

## 光照
## Pass
顺序为:
1. Outline
2. ForwardLit
3. ShadowCaster
4. DepthOnly

模板测试语法:
```c#
Stencil
{
    Ref[_StencilNo]             //设置渲染的模板缓存值,0~255
    Comp[_StencilComp]          //模板测试的通过条件,有除了equal,还有Greater、Less、Always、Never等,类似ZTest。
    Pass[_StencilOpPass]        //表示通过模板测试和Z测试(注意是都通过)的像素,怎么处置它的模板值。
    Fail[_StencilOpFail]        //表示通过了模板测试但没通过Z测试的像素,怎么处置它的模板值。
}
```

### Outline
```c#
Tags {"LightMode" = "SRPDefaultUnlit"}:使用这个LightMode标签值在渲染物体时绘制一个额外的Pass。也是URP光照模式的默认值。
Cull [_SRPDefaultUnlitColMode]
ColorMask [_SPRDefaultUnlitColorMask]
Blend SrcAlpha OneMinusSrcAlpha
Stencil
{
    Ref[_StencilNo]
    Comp[_StencilComp]
    Pass[_StencilOpPass]
    Fail[_StencilOpFail]
}
```
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "UniversalToonHead.hlsl"
#include "UniversalToonOutline.hlsl"

### ForwardLit
```c#
Tags{"LightMode" = "UniversalForward"}:URP前向渲染
ZWrite[_ZWriteMode]
Cull[_CullMode]
Blend SrcAlpha OneMinusSrcAlpha
Stencil {

    Ref[_StencilNo]

    Comp[_StencilComp]
    Pass[_StencilOpPass]
    Fail[_StencilOpFail]

}

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
#include "UniversalToonHead.hlsl"
#include "UniversalToonBody.hlsl"
```

### ShadowCaster
渲染阴影贴图

```c#
Name "ShadowCaster"
Tags{"LightMode" = "ShadowCaster"}

ZWrite On
ZTest LEqual
Cull[_CullMode]

#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
```

### DepthOnly
渲染深度缓存

```c#
Tags{"LightMode" = "DepthOnly"}

ZWrite On
ColorMask 0
Cull[_CullMode]

#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
```