RenderTexture vs. Grabpass

Hey everyone,

I would like to know which one is the fastest and what are the pros and cons for each of them according to this context.

When creating image effects adding an extra pass with Grabpass and using the result in the shader.
Using a potential down-sampled version of the source RenderTexture inside OnRenderImage assigned with GetTemporary.

Thank you !

The only pro of a grab pass is easy implementation as it does a lot of things for you. It creates a temporary RenderTexture, then blits the exact copy of the source texture into it and assigns it to your shader. That’s great for rendering world space objects where you can’t guarantee that it will cover the entire screen, so you need to copy the source yourself. For image effects, however, you do know they cover the entire screen, so the copy is unnecessary. That means that coding your own rendering logic inside OnRenderImage can be faster, because it can be done with a single blit, as opposed to two.

Downsampling the source RenderTexture does not make much sense to me, unless you’re about to do some crazy sampling on it. Could you elaborate more on what you want to achieve?

1 Like

Thank you very much @Dolkar for your answer.

My question about downsampling can be linked with blur and the advantage of downsampling a RenderTexture in general. What are the condition that might require downsampling something ?

In my opinion, downsampling when you blit using a shader saves processing as there are less pixels (or texels ?) to treat. It also reduce the texture memory. It’s better to process a downsampled version of the source than the full source when you blit it using a shader.

A shader is executed on every pixel of the target render texture. That means if the target texture has lower resolution, then it reduces processing time considerably. However, how you said it makes it sound like you’re just downscaling a full screen texture into a half res one, then you bind it to your blurring shader and run that one with a full screen texture as a target. Whether that benefits performance over sampling the full screen texture directly is at best arguable, because the number of texture reads still depends on the number of pixels the shader is executed on.

What you should be doing is creating a half resolution (or even smaller) temporary render texture, then run a blurring shader with it as the target, sampling from the full resolution source texture. You then end up with a half resolution blurred texture, for which you need another, now full res pass, that upscales it back, blurring it even further.

Alright @Dolkar , thank you again, this is now clear for me !