I’m trying to write a simple shader where I just copy the current frame of the program into the shader via the shader.set function:
PShader shader;
PImage screen;
void setup(){
size(1000, 1000, P2D);
shader = new PShader(this, "Vert.vert", "Frag.frag");
loadPixels();
for(int i = 0; i < pixels.length; i++){
pixels[i] = color(map(i, 0, pixels.length, 0, 255), 0, map(i, 0, pixels.length, 255, 0));
}
updatePixels();
noStroke();
}
void draw(){
screen = get();
shader(shader);
shader.set("text", screen);
rect(0, 0, width, height);
}
Fragment Shader:
varying vec2 va_pos;
uniform sampler2D text;
void main(){
gl_FragColor = texture2D(text, va_pos);
}
As described in the title, the program does not show a gradient between blue and red. The complete window ist just filled with a purple color