Quote:Original post by MJPQuote:Original post by Tree PenguinQuote:Original post by taby
I suppose you could scan through the entire texture using a sampler2D from within the shader, but that would be a ridiculously huge waste of GPU time.
For postprocessing (doing hdr adjustments etc) that's a good way to do it. The shader would be heavy, but you only run it for one pixel, so it's not that bad.
The "run once per pixel" part is precisely what makes that method such a bad idea. A modern high-end GPU can potentially execute hundreds pix pixel shaders simultaneously, and will have a several dozen texture units available for sampling. Having a single shader that performs all of the texture sampling means that you don't make use of all of that hardware available to you.
What I think he was referring to was setting up an offscreen buffer of size 1x1, so even though it's run once per pixel, there's only one pixel being rendered in the first place (hopefully we're on the same page). Now, samoth's idea is a little better since he does the same thing, but sets up an FBO of size 1xn, where n is the number of lines in the texture to be enumerated, thus taking advantage of the parallelism that you speak of.
Either way, both methods involve amortized costs. We're not talking about calculations done per-frame, but literally only once. I am uncertain that we are all on the same page here. In fact, I think his comment about HDR is because we're not all on the same page, so the confusion has only been compounded. :)