屏幕后处理方案

后处理效果的性能问题主要在

1. 屏幕每个像素都要进行计算。

2. 可能会创建多张RenderTexture的空间占用。

3. 多次Blit操作,比如高斯模糊多次迭代。

4. 偶尔还需要新建摄像机渲染到RenderTexture。

 

方法一

Camera的Target Texture保持为空,通过在OnRenderImage函数内,调用Graphics.Blit方法实现后处理。

缺点:If you did not supply a RenderTexture to the camera's targetTexture, Unity will trigger CPU ReadPixel (Get data back from GPU), which will stall the whole GPU until finish. Super slow

参考:Post Process Mobile Performance : Alternatives To Graphics.Blit , OnRenderImage

 

方法二

为Camera的Target Texture指定一个RT,直接渲染到RT。

问题:当Camera开启MSAA或者HDR的时候,会导致后处理不起效果,猜测在开启HDR的时候,会创建一个HDR RenderTexture,相机的绘制都会写入HDR的RT里。

 

引用:

https://zhuanlan.zhihu.com/p/39850106

posted @ 2021-01-05 17:35  何文西  阅读(195)  评论(0编辑  收藏  举报