- Home /
Does Graphics.Blit affect performance much when used in image effects?
Hi.
I've coded several image effects which modify a passed texture using Graphics.Blit with specific shader and pass it to a next effect. Forming a chain of effects. You know, like an algorithm: 1. blur, 2. threshold, 3. edge detect.
This chain has many calls to Graphics.Blit, which as I understand is a separate draw call itself.
So, is it a good approach or I'll get myself into serious performance problems pretty soon?
If you can combine effects then do - but I'm guessing that many of those effects need to process the previous result - so you have little choice?
Yeah, effects need result of previous ones. I just wonder how much this will hurt performance. If I got like 100 of them combined == 100 more draw calls.
The question is are these draw calls lightweight or it doesn't matter? I'd guess that uploading a quad and initializing a texture with a shader wouldn't be such a bottleneck. Comparing to rendering huge meshes with giant shaders.
100 - wow - I can't wait to see what you are making! $$anonymous$$ust be amazing!
Well if the quads cover the whole screen then you have $$anonymous$$imum 100x full screen resolution overdraw which might screw up fill rate on some devices (and clearly would never fly on mobile platforms).
So no they aren't lightweight - they're pretty heavy because lets face it the vertex part of a shader is called a lot less than the fragment part - then you've got auto culling due to obscured depth normally etc etc.
Answer by ricardo_arango · Apr 21, 2013 at 05:46 PM
Having them as separate scripts gives you flexibility to add/remove/disable/enable them as needed. But for performance reasons it would be best to combine the effects into a single OnRenderImage call when possible.
So a better approach is to combine as many of your effects as you can into a single effect. Every Graphics.Blit of a fullscreen quad is of course expensive, therefore the less you do it, the more you save.
You can also render to a RenderTexture instead of to the screen, as this will read back from screen to the Texture pass to OnRenderImage.
Finally, you can also downscale your RenderTexture which will reduce the number of texels from the RenderTexture that have to be processed and improve performance.
I am using RenderTexture only rendering. Nothing goes to screen in this chain.
Your answer
Follow this Question
Related Questions
Need Help Getting RenderTexture & Graphics.Blit Working: Boosting Mobile Performance 0 Answers
Blitting a Texture once 0 Answers
Multiple Blit problem 2 Answers
Render to texture, use same texture as input in next render call 0 Answers
ReadPixels Performance 0 Answers