At first I was rendering my scene (on iOS / Unity 4.2) in the following order:
- Render scene with postprocessing using OnRenderImage
- Render UI
Rendered seperately step 1 cost about 16ms and the UI 8 ms.
But I wanted to perform the postprocessing on both the scene and UI combined, so I changed it to
- Render scene
- Render UI with postprocessing using OnRenderImage
To my surprise my rendering now cost about 280ms! Crazy!
In my profiler “Camera.AAResolve” showed up twice taking up about 250ms.
AAResolve makes me think this is anti-aliasing related, even though it’s turned off everywhere (bug?)
On the unity3d IRC chat someone told me that this always happens on iOS when you have more than 1 camera and perform postprocessing on a camera other than the first.
This is probably a bug.
It took me a couple of days to figure out a solution, but since I couldn’t find a solution myself I figured I’d share it with the internet.
The trick is to set up (and create) all your rendertextures in OnPreRender/OnPostRender manually, then you can work around this AAResolve thing which only seems to happen when you use OnRenderImage.
Hope this avoids you some headaches!