- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

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.

Class | PShader
Name | ### set()
Examples |
    PImage tex;
    PShader deform;

    void setup() {
      size(640, 360, P2D);
      tex = loadImage("tex1.jpg");
      deform = loadShader("deform.glsl");
      deform.set("resolution", float(width), float(height));
    }

    void draw() {
      deform.set("time", millis() / 1000.0);
      deform.set("mouse", float(mouseX), float(mouseY));
      shader(deform);
      image(tex, 0, 0, width, height);
    }
Description | Sets the uniform variables inside the shader to modify the effect while the program is running.
Syntax |
    .set(name, x)
    .set(name, x, y)
    .set(name, x, y, z)
    .set(name, x, y, z, w)
    .set(name, vec)
    .set(name, vec, ncoords)
    .set(name, boolvec, ncoords)
    .set(name, mat)
    .set(name, mat, use3x3)
    .set(name, tex)
Parameters |
name | String: the name of the uniform variable to modify
x | boolean, float, or int: first component of the variable to modify
y | boolean, float, or int: second component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[2], vec2)
z | boolean, float, or int: third component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[3], vec3)
w | boolean, float, or int: fourth component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[4], vec4)
vec | boolean[], float[], int[], or PVector: modifies all the components of an array/vector uniform variable. PVector can only be used if the type of the variable is vec3.
ncoords | int: number of coordinates per element, max 4
mat | PMatrix3D, or PMatrix2D: matrix of values
use3x3 | boolean: enforces the matrix is 3 x 3
tex | PImage: sets the sampler uniform variable to read from this image texture
Returns | void

Updated on January 9, 2020 00:33:14pm EST