Fastest way to render objects that rely the current screen color in mobile? (similar to grabpass)

Most mobiles are tiled base GPU, switching RenderTarget is expensive(resolve color), start rendering into a RenderTexture without clear will trigger “Restore”, which pulls data back from slow ram.

I am in a situation that I need to render distortion for some object(Sword trails), but it always triggers that tiled GPU performance warning:

Tiled GPU perf. warning: RenderTexture color surface  (1920x1080) was not cleared/discarded, doing Camera.Render/Drawing

my current distortion objects(Sword trails) render logic are as follow:

--------------------------------
Target results are the following(distortion only inside an object, not full screen):

wonder if the above render logic is already the fastest? if not, are there any better solution?

Are you using CommandBuffers on the Camera? Or the regular Graphics.Blit sort with OnRenderObject etc?

regular Graphics.Blit on camera’s OnPostRender()

I’m not an expert but it seems to me that your problem with not clearing stems from trying to do stuff after camera has rendered.
CommandBuffers offer same stuff but you can inject them in between rendering stages and that goes for before and after most of them.

@npatch1 thanks for the reply!
yes, I understand CommandBuffer can inject rendering calls between rendering stages.

Maybe I should explain the situation more,
there are 2 RenderTextures needed in my rendering logic.
Let’s call the RenderTexture that do all the regular rendering - “MainRT”(RT size = ScreenSize)
and another RenderTexture that just for storing a COPY of the above “MainRT”, named “CopyRT”(RT size = 1/4 ScreenSize).

Because I need to copy “MainRT”'s content into “CopyRT”(just for being sampled by sword trails later), a render target switch from “MainRT” → “CopyRT” seems a must.

Switching render target from “MainRT” → “CopyRT” is not the problem part.
The problem part is I need to render sword trails back into the “MainRT”(that texture that do regular rendering before).
This triggers “Tiled GPU perf.” which copys “MainRT”'s original content back from slow ram.

The reason why I need to render sword trails into “MainRT” after the copy(even it triggers tiled GPU restore warning), is because at the final stage, I can make sure everything can apply image effect together.

So maybe there are better method to do per object postprocess in mobile?

From what documentation says about Blit(both Graphics and CommandBuffer APIs), it sets dest as the active render target. I guess that’s where the switch originates.
In that case use Graphics.CopyTexture. Documentation on CopyTexture does not mention anything about switches on RenderTarget.

1 Like