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.

Name

PShader

Examples
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);
  rectMode(CENTER);
}

void draw() {
  filter(blur);  
  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.]
Methods
set() Sets a variable within the shader
Constructor
PShader()
PShader(parent)
PShader(parent, vertFilename, fragFilename)
PShader(parent, vertURL, fragURL)
PShader(parent, vertSource, fragSource)
Parameters
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 January 1, 2021 03:38:10am EST