Jeff Russell
05-17-2007, 03:46 PM
Hi everyone,
I'm beginning to create a real time exposure adjustment effect in OpenGL, and before I hit my head on too many walls I thought I'd ask for some general advice from this board.
My situation basically is this - I have an fp16 texture to which my scene is being rendered through a framebuffer object. It is as you would expect large (same as screen resolution), and not power of two. I can re-render this to the color buffer with any exposure function I like using a screen aligned quad. So far, so good.
The problem is that for an effect simulating a human eye's response to brightness changes, I need some value as input that is the current brightness of the scene, or even better yet some kind of short-term running average to serve as sort of a 'history' of brightness to provide a time delayed response to brightness changes.
Now, it would seem that if I could just mipmap my render target, the 1x1 mipmap level would provide exactly that value - the average intensity of all the texels in the full res image. So I've tried this through the glGenerateMipmapEXT call; and it brings the app to a grinding crawl and doesnt even seem to work. (geforce 7900, newish drivers).
I've considered manual 'mipmapping', where I use a convolution shader and several render passes over quads to shrink this image into a 1x1 block which I could use GPU side as input to exposure adjustment. My recollection is that this technique is generally considered the way to go for this sort of thing in floating point - am I missing anything here? I could even cut some corners for performance as long as largish features of my original image aren't missed in the downsampling.
As sort of a secondary question, would it be a good idea / feasible to read back this brightness value onto the CPU somehow, through the use of PBO's or the like? If latency becomes a problem, I think I could deal with a frame of lag or so on the value. I'm assuming glGetTexImage is too slow :-P
If anyone here has any advice or related experience on this matter, I'd be quite happy to hear it!
Thanks
I'm beginning to create a real time exposure adjustment effect in OpenGL, and before I hit my head on too many walls I thought I'd ask for some general advice from this board.
My situation basically is this - I have an fp16 texture to which my scene is being rendered through a framebuffer object. It is as you would expect large (same as screen resolution), and not power of two. I can re-render this to the color buffer with any exposure function I like using a screen aligned quad. So far, so good.
The problem is that for an effect simulating a human eye's response to brightness changes, I need some value as input that is the current brightness of the scene, or even better yet some kind of short-term running average to serve as sort of a 'history' of brightness to provide a time delayed response to brightness changes.
Now, it would seem that if I could just mipmap my render target, the 1x1 mipmap level would provide exactly that value - the average intensity of all the texels in the full res image. So I've tried this through the glGenerateMipmapEXT call; and it brings the app to a grinding crawl and doesnt even seem to work. (geforce 7900, newish drivers).
I've considered manual 'mipmapping', where I use a convolution shader and several render passes over quads to shrink this image into a 1x1 block which I could use GPU side as input to exposure adjustment. My recollection is that this technique is generally considered the way to go for this sort of thing in floating point - am I missing anything here? I could even cut some corners for performance as long as largish features of my original image aren't missed in the downsampling.
As sort of a secondary question, would it be a good idea / feasible to read back this brightness value onto the CPU somehow, through the use of PBO's or the like? If latency becomes a problem, I think I could deal with a frame of lag or so on the value. I'm assuming glGetTexImage is too slow :-P
If anyone here has any advice or related experience on this matter, I'd be quite happy to hear it!
Thanks