I have a very simple OpenGL view rendering 2 triangles with a single texture applied. The minimum setup for rendering a 2d game.
What i do is redraw the texture for every frame and easily get 60fps.
I would like to add an effect simulating LCD slow response by outputting pixels that are the average between the current and the previous frame.
The pseudo code of fragment shader would look like this
varying vec2 v_TexCoordinate;
uniform sampler2D u_Texture;
void main() {
gl_FragColor = (texture2D(u_Texture, v_TexCoordinate) + PIXEL_PREVIOUS_FRAME) / 2;
PIXEL_PREVIOUS_FRAME = gl_FragColor;
};
Well, i think shaders can't keep a persistent variable like PIXEL_PREVIOUS_FRAME, then i really don't know how to tackle this problem.
Any suggestion?