[SOLVED] Method of blitting a downsampled texture :)

Hello!

Today I’ve tried to implement some post effects using progressive downsampling of the original texture. For that, I need to keep an array of textures (1x, 0.5x, 0.25x etc) and then blit step by step downsampling by factor of two each step.

So when I try to do copyRenderTarget, and my source RT is say 1024 pixels, and my destination RT is 512 pixels, I only get a portion of the source render target in the target render target! Which is very sad.

Can I somehow blit different size render targets without loosing any texture info in process?

Might there also be some fast way (I need this in onUpdate) to get downsampled version of texture I already have? I thought process was that copyRenderTarget will be the fastest way available.

Thanks.

Having a quick look, it seems that copyRenderTarget uses the same dimensions for source and destination, which explains what you’re seeing. Ideally it would handle scaling as well, but currently does not.

You could probably just copy this function to your code and modify it as needed.

Alternatively you can render a quad and copy pixels using a shader. The simplest example using shaders is probably here:

see drawQuadWithShader there.

3 Likes

What a nice set of options, thanks a lot @mvaligursky!

ooooh, what a nice thing to have!

look, here I have a downsampled image:

and here I have progressively downsampled image:

very very good results! thanks @mvaligursky

3 Likes