Here’s the simpler version of your code working off of that blur example:
PImage img;
PShader shader;
void setup() {
size(640, 480, P2D);
img = loadImage(dataPath("image.jpg"));
shader = loadShader("frag.glsl");
}
void draw() {
background(127); // set background color to gray
image(img, 0, 0, width, height);
filter(shader);
}
with no vertex.glsl file. The frag.glsl file is:
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D texture;
varying vec4 vertTexCoord;
void main() {
vec4 col = texture2D(texture, vertTexCoord.st);
gl_FragColor = vec4(col.r, 0.0, 0.0, col.a); // keep only the red channel
}