View Full Version : Average of the pixels
02-13-2007, 05:50 PM
Is it possible to take average of pixels rendered each time.
02-13-2007, 05:51 PM
Sorry, I mean the average of the pixels rendered at location (i,j) of the framebuffer
02-14-2007, 01:47 AM
Yes, it is possible, but not easy.
What you need to do is to keep track of how many pixels you have rendered.
And to do that you need to render everything twice to individual textures, once normally but with (GL_ONE,GL_ONE) blending, and the other one to count how many pixels are rendered(same blending as the first one but with the darkest color above pure black you can get).
then you can combine them in a texture and get the average from that.
As i said, it's possible, but not easy.
02-16-2007, 12:12 PM
You can use the accumulation buffer. Basically you would be creating a motion blur effect. First clear the accumulationg buffer. Then, draw succesive frames adding into the accumulation buffer and keep track of how many frames you've drawn. Then readback from the accumulation buffer and divide by the number of frames you've drawn. That should give you pixel averages. The accumulation buffer is usually 16 bit so as long as you don't add too many frames, you should be getting enough precision.
02-17-2007, 05:01 AM
The accumulation buffer is usually not hardware accelerated. Better use zeoverlords method, but for this you need a float render target to prevent saturation.
You can use the alpha channel to count how often the pixels are rendered, so you don't need another pass for that.
03-02-2007, 10:41 PM
Thanks a lot, But how to do it with alpha channel.
Please suggest with some code
Thanks a lot
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.