- 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.

Name | ### loadShader()
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 | Loads a shader into the PShader object. The shader file must be loaded in the sketch's "data" folder/directory to load correctly. Shaders are compatible with the P2D and P3D renderers, but not with the default renderer. Alternatively, the file maybe be loaded from anywhere on the local computer using an absolute path (something that starts with / on Unix and Linux, or a drive letter on Windows), or the filename parameter can be a URL for a file found on a network. If the file is not available or an error occurs, null will be returned and an error message will be printed to the console. The error message does not halt the program, however the null value may cause a NullPointerException if your code does not check whether the value returned is null.
Syntax |
    loadShader(fragFilename)
    loadShader(fragFilename, vertFilename)
Parameters |
fragFilename | String: name of fragment shader file
vertFilename | String: name of vertex shader file
Returns | PShader

Updated on January 1, 2021 03:38:07am EST
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.