Forward模式下,当使用CommandBuffer来实现后处理的时候,发现cb.Blit(BuiltinRenderTextureType.CameraTarget,...)无效,在FrameDebug中看到传入的_MainTex为Whilte,(在Deferred渲染模式下有效)
原因:
在Forward模式下,默认相机是渲染到BackBuffer,而在渲染的时候,无法直接读取BackBuffer(Deffered模式下有GBuffer,所以没有问题),解决办法,手动Grab一次(调用cb.Blit指定入材质即可,有额外性能消耗),或者相机开启forceIntoRenderTexture。(注:必须5.6以后才生效,如果开启了HDR或者使用了OnRenderImage则不需要开启(5.6以上))
类似问题:
So it seems that when OnRenderImage is being used, or when HDR rendering is on, or when anything that needs the camera to render to an intermediate buffer is enabled, the camera automatically renders to an intermediate buffer instead of the backbuffer (screen) directly. This is nice.