This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.



PShader blur;

void setup() {
  size(640, 360, P2D);
  // Shaders files must be in the "data" folder to load correctly
  blur = loadShader("blur.glsl"); 
  stroke(0, 102, 153);

void draw() {
  rect(mouseX-75, mouseY, 150, 150); 
  ellipse(mouseX+75, mouseY, 150, 150);
Description This class encapsulates a GLSL shader program, including a vertex and a fragment shader. It's compatible with the P2D and P3D renderers, but not with the default renderer. Use the loadShader() function to load your shader code. [Note: It's strongly encouraged to use loadShader() to create a PShader object, rather than calling the PShader constructor manually.]
set() Sets a variable within the shader
PShader(parent, vertFilename, fragFilename)
PShader(parent, vertURL, fragURL)
PShader(parent, vertSource, fragSource)
parent PApplet: the parent program
vertFilename String: name of the vertex shader
fragFilename String: name of the fragment shader
vertURL URL: network location of the vertex shader
fragURL URL: network location of the fragment shader
Updated on September 22, 2016 07:39:36pm EDT

Creative Commons License