PGraphics pong;

PShader diff;

void setup(){

size(800, 800, P2D);

pong = createGraphics(width, height, P2D);

diff = loadShader("diffFrag.glsl");

pong.beginDraw();

pong.background(255, 0, 0);

pong.endDraw();

diff.set("u", 1.0/width);

diff.set("v", 1.0/height);

pong.beginDraw();

pong.noStroke();

pong.fill(0, 255, 0);

pong.ellipse(width/2, height/2, 10, 10);

pong.endDraw();

}

void draw(){

pong.beginDraw();

pong.shader(diff);

pong.image(pong, 0, 0);

pong.resetShader();

pong.endDraw();

image(pong, 0, 0);

}

//// diffFrag.glsl

varying vec4 vertColor;

varying vec4 vertTexCoord;

uniform float u;

uniform float v;

uniform sampler2D texture;

float laplaceA(in vec2 p, in float u, in float v){

float A = 0.05 * texture2D(texture, vertTexCoord.st + vec2(-u,-v))[0] + 0.2 * texture2D(texture, vertTexCoord.st + vec2(0,- v))[0] + 0.05 * texture2D(texture, vertTexCoord.st + vec2(u,-v))[0] +

0.2 * texture2D(texture, vertTexCoord.st + vec2(-u,0))[0] - 1.0 * texture2D(texture, vertTexCoord.st + vec2(0,0))[0] + 0.2 * texture2D(texture, vertTexCoord.st + vec2(u, 0))[0] +

0.05 * texture2D(texture, vertTexCoord.st + vec2(-u,v))[0] + 0.2 * texture2D(texture, vertTexCoord.st + vec2(0,v))[0] + 0.05 * texture2D(texture, vertTexCoord.st + vec2(u,v))[0];

return A;

}

float laplaceB(in vec2 p, in float u, in float v){

float B = 0.05 * texture2D(texture, vertTexCoord.st + vec2(-u,-v))[1] + 0.2 * texture2D(texture, vertTexCoord.st + vec2(0,- v))[1] + 0.05 * texture2D(texture, vertTexCoord.st + vec2(u,-v))[1] +

0.2 * texture2D(texture, vertTexCoord.st + vec2(-u,0))[1] -1.0 * texture2D(texture, vertTexCoord.st + vec2(0,0))[1] + 0.2 * texture2D(texture, vertTexCoord.st + vec2(u, 0))[1] +

0.05 * texture2D(texture, vertTexCoord.st + vec2(-u,v))[1] + 0.2 * texture2D(texture, vertTexCoord.st + vec2(0,v))[1] + 0.05 * texture2D(texture, vertTexCoord.st + vec2(u,v))[1];

return B;

}

void main(){

float A = texture2D(texture, vertTexCoord.st )[0] ;

float B = texture2D(texture, vertTexCoord.st )[1] ;

float A_1 = A + (0.9 * laplaceA(vertTexCoord.st, u , v) - A * B * B + 0.0545 * (1 - A)) ;

float B_1 = B + ( 0.18 * laplaceB(vertTexCoord.st, u, v) + A * B * B - (0.062 + 0.0545) * B) ;

gl_FragColor = vec4(A_1, B_1, 1.0, 1.0);

}

Tip: try to change the numerical values in the definition of A_1 and B_1 in the fragment shader code.

*: A fragment shader technically deals with fragments rather than pixels.