In an effort to teach myself OpenGL, I am working my way trough the 5th edition of the Superbible.
I am currently trying to figure out how to combine HDR and MSAA (as de
As far as I see from your GLSL code the weight for all samples of a pixel are equal. From that I conclude that the code is interested in the sum of those samples for each pixel. The sum is an average multiplied by the number of samples. From here at least two optimization techniques reveal. Both are using an intermediate single-sampled texture, from which your code is supposed to sample instead of the original multi-sampled one:
(doing it precise to what you are doing). Produce an intermediate texture with a shader that writes average of the samples for each pixel.
(approximating quickly). Let the intermediate texture to be just the resolved original one. Can be done effectively by calling glBlitFramebuffer()
. This will produce slightly different result (because the sample locations are not on a grid), but for you task - HDR - it shouldn't matter, as it's all pretty much an approximation :)
Good luck!