Previous pixel values in the fragment shader

Hi, is it possible and how to get the previous pixel values in the fragment shader ?
(glsl v 1.3)
Thanks

Directly? Nope. Once you clear the back buffer the values are gone.

Still, you can of course create your own buffer to which you copy the contents of the back buffer before clearing and bind the color attachment as a 2D texture and access it from within the shader.

This will work from frame 1 (assuming frame 0 to be the first):

a) At init time, create a FBO with a color attachment matching the dimensions of the default framebuffer (or another FBO if any)
b) After rendering frame n, blit the contents of the current draw buffer to the temporary buffer used in frame n + 1
c) While rendering frame n + 1, bind the color attachment of the temporary buffer (containing the color values of frame n)
d) Access arbitrary color values inside a shader using texture lookups

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.