随着渐渐开学了,事也变得越来越多了了起来。所以自学的时间也就意味着变得越来越少了起来,但希望还是不忘初心,继续努力。
废话不多说,开始我们的学习。这次我们学习的是屏幕后处理效果,这是游戏中实现屏幕特效的常见方法,所谓屏幕后处理效果,顾名思义,就是在渲染完整个场景后,再对屏幕实现一系列操作,实现各种特效。
这一篇我们先实现一些简单的效果----------亮度、饱和度、对比度。
在屏幕后处理之前我们需要检查一系列条件是否满足,例如当前平台是否支持渲染纹理和屏幕特效、是否支持当前使用的Unity shader等。这里我们先创建一个c#脚本:
[ExecuteInEditMode]
[RequireComponent (typeof(Camera))]
public class PostEffectsBase : MonoBehaviour {
// Called when start
protected void CheckResources() {
bool isSupported = CheckSupport();
if (isSupported == false) {
NotSupported();
}
}
// Called in CheckResources to check support on this platform
protected bool CheckSupport() {
if (SystemInfo.supportsImageEffects == false || SystemInfo.supportsRenderTextures == false) {
Debug.LogWarning("This platform does not support image effects or render textures.");
return false;
}
return true;
}
// Called when the platform doesn't support this effect
protected void NotSupported() {
enabled = false;
}