BlueRoseNote/07-Other/Unity/Unity-Chan 2种模式比对.md
2023-06-29 11:55:02 +08:00

48 lines
3.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 公式
```c#
saturate((1.0 + ( (Set_ShadingGrade - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_1st_ShadeColor_Step - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)))); // Base and 1st Shade Mask
```
## ShadingGradeMap
```c#
float3 Set_BaseColor = lerp( (_MainTex_var.rgb*_BaseColor.rgb), ((_MainTex_var.rgb*_BaseColor.rgb)*Set_LightColor), _Is_LightColor_Base );
float3 _BaseColor_var = lerp(Set_BaseColor,_Is_LightColor_1st_Shade_var,Set_FinalShadowMask);
float Set_FinalShadowMask = saturate((1.0 + ( (Set_ShadingGrade - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_1st_ShadeColor_Step - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather))));
float Set_ShadeShadowMask = saturate((1.0 + ( (Set_ShadingGrade - (_2nd_ShadeColor_Step-_2nd_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_2nd_ShadeColor_Step - (_2nd_ShadeColor_Step-_2nd_ShadeColor_Feather))));
float3 Set_FinalBaseColor = lerp( _BaseColor_var,
lerp(_Is_LightColor_1st_Shade_var,
lerp( _2nd_ShadeMap_var.rgb*_2nd_ShadeColor.rgb,
((_2nd_ShadeMap_var.rgb*_2nd_ShadeColor.rgb)*Set_LightColor),
_Is_LightColor_2nd_Shade ),
Set_ShadeShadowMask),
Set_FinalShadowMask);
```
## Feather
```c#
_Set_1st_ShadePosition与 _Set_2st_ShadePosition默认为白色。
float3 Set_BaseColor = lerp( (_BaseColor.rgb*_MainTex_var.rgb), ((_BaseColor.rgb*_MainTex_var.rgb)*Set_LightColor), _Is_LightColor_Base );
float Set_FinalShadowMask = saturate(1.0 + lerp( _HalfLambert_var,
_HalfLambert_var*saturate(_SystemShadowsLevel_var),
_Set_SystemShadowsToBase ) - (_BaseColor_Step-_BaseShade_Feather) *
((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0) //对应上面的 (0.0 - 1.0)项
/ (_BaseColor_Step - (_BaseColor_Step-_BaseShade_Feather)));
float3 Set_FinalBaseColor = lerp( Set_BaseColor,
lerp(Set_1st_ShadeColor,
Set_2nd_ShadeColor,
saturate((1.0 + ( (_HalfLambert_var - (_ShadeColor_Step-_1st2nd_Shades_Feather)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0) ) / (_ShadeColor_Step - (_ShadeColor_Step-_1st2nd_Shades_Feather))))
),
Set_FinalShadowMask); // Final Color
```
## 总结
可以看得出两者都使用了UTS的祖传公式进行插值。但不同点在于
- ShadingGradeMap工作模式的UTS公式插值对象为ShadingGradeMap之后使用1st、2stShadeColor对应的Step与Feather进行计算来获得2个ShadeMask。最后再使用2个Mask对BaseColor、1stShadeColor与2stShadeColor进行插值来获取最终结果。
- Feather工作模式的UTS公式插值对象为HalfLambert之后也使用2份Step与Feather进行计算得到来获得2个ShadeMask。最后再使用2个Mask对BaseColor、1stShadeColor与2stShadeColor进行插值来获取最终结果。还有一个区别在于里面增加了ShadePositionMap对UTS公式的分子项进行控制也就是使用`(1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)`来代替`(0.0 - 1.0)`