Skip to main content
GameDev.net gamedev.net
🔒 Locked

pixel Readback - downsampling texture beforehand ?

Started by UnshavenBastard Jun 20, 2010 at 12:20 AM 1 replies 1.3k views
Original Post
UnshavenBastard
UnshavenBastard
Howdy, fellas.

Assuming that I do everything fixed pipeline here:

(I remember that I have read about this subject, but can't find it again *grumbles*)

Say I rendered some stuff in an FBO, and want to read back its texture's pixels from the GPU, with eg. glReadPixels(..).
Assume further, I don't need the full resolution, but some down-sampled version, like a mipmap from 256² to 32² or so, would do.

Can I do that (downsampling), using fixed function commands only, completely GPU internal without much overhead, to gain speed for the readback?

It would be extra sweet if, using a floating point texture, this could go down to the point that I read back only 1 pixel, since I'm interested in the RGB value sum of all pixels.


Have a nice day,
unshaven

[Edited by - UnshavenBastard on June 20, 2010 11:41:39 AM]
Geometrian
Geometrian
Hi,

If you can get mipmapping on your FBO, you can simply render a mipmapped fullscreen quad with a view size of 1x1. You can then just get the color of this pixel through your favorite method.

Ian
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
UnshavenBastard
UnshavenBastard
But if I tell the thing to generate mipmaps the regular way, will I not have to generate many stages after another, to finally arrive at 1x1 ? (or depending on how I tell the GPU to do it, it might generate several stages at once automatically, but I guess this costs time and memory unnecessarily)

I was hoping there might be a way to just do one round of downsampling, to arrive at my desired resolution :-)

---------
EDIT:

I stumbled upon the command glBlitFramebuffer. My main machine's card supports it, which shall suffice for now.
I wasn't aware of it, that it could blit into a texture of different size, it might be doing what I want here, although the document speaks of "stretching" the one buffer over the other if the source/dest rectangles do not match, using linear interpolation if specified so -
- but what in the opposite case, if dest is smaller than source... ? (I guess that stretching does not allow the meaning of down-sampling, although English is not my first language, who knows... ;) )
And - is this FAST ? Anybody here got experience with this?

[Edited by - UnshavenBastard on June 22, 2010 4:04:13 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.