Multiple frames blending

Hello everyone. I am currently using a shader to render a map on a texture. Since the application has to be real-time and the map accuracy requires multisampling I decided that, instead of doing the sampling in the shader and then outputting the map, I would instead blend the texture over subsequent rendering.
Ideally I would like to use the 5 previous rendering + the new one and combining them by giving more weight to the latest rendering and least weight to the first. The very first frames are obviously going to be very noisy but after the sixth one I should be able to see a “slightly” flickering version of what I wanted. Is there an efficient way to do this? I am already doing quite some computation so I would prefer a very light solution.

For legacy implementations/tutorials, websearch “opengl accumulation buffer”. You can of course implement this nowadays with off-screen FBOs however you desire.

thanks for the answer, I have seen that accumulation buffer has now deprecated. I was thinking of using FBOs (I already do deferred shading and render to 3 targets) but wouldn’t it be too expensive? Also, if this is the best way to go, should I use a gbuffer instead of textures?

That depends on a lot of things. How you do it. What frame time you’ve got available for it. What hardware/driver you’ve got, and its particular performance (cost of rebinding FBOs, etc.)

Also, if this is the best way to go, should I use a gbuffer instead of textures?

This didn’t make sense to me. It’s apples and oranges in a few ways. First, GBuffer would typically be comprised of textures, for the reason that you need to read them back into the shader pipeline in a later pass. Also, the GBuffer contains materials properties, not scene radiances or luminances (e.g. screen colors), but what I assume you want to blend is not the former, but the latter.

I am usign a Geforce gt540m. Right now I do a shadowmap pass (one FBO) then I perform a 3d texture writing using imageStore, then I render 2 textures (one with normals+depth and the other with color in one FBO with 3 targets), then I render this map based on normals+depth and the 3d texture (same FBO, last target) and then I blend everything in a final pass.