Unity屏幕灰化效果
发表于2020-04-30
1. 屏幕灰化效果简述
一般由于政策特殊日期等因素,或者游戏内角色死亡效果要求等等,我们会想看到一个整体灰色的效果。具体表现测试效果:

2. 需要了解
Unity后处理OnRenderImage
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnRenderImage.html
Graphics.Blit
https://docs.unity3d.com/ScriptReference/Graphics.Blit.html
Copies source texture into destination render texture with a shader.
在后处理中调Graphics.Blit传入一个改变颜色饱和度的shader,即可实现想要的灰色效果。
3. 具体shader

4. C#脚本
变量

兼容判断(不支持的话会造成卡帧等等)

可动态调整灰度值,看后处理渲染出的灰色效果

脚本挂在相机上即可。
