Py5Shader#

This class encapsulates a GLSL shader program, including a vertex and a fragment shader.

Examples#

 1def setup():
 2    global blur
 3    py5.size(640, 360, py5.P2D)
 4    # shaders files must be in the "data" folder to load correctly
 5    blur = py5.load_shader("blur.glsl")
 6    py5.stroke(0, 102, 153)
 7    py5.rect_mode(py5.CENTER)
 8
 9
10def draw():
11    py5.apply_filter(blur)
12    py5.rect(py5.mouse_x-75, py5.mouse_y, 150, 150)
13    py5.ellipse(py5.mouse_x+75, py5.mouse_y, 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 load_shader() function to load your shader code and create Py5Shader objects.

Underlying Processing class: PShader

The following methods and fields are provided:

  • set(): Sets the uniform variables inside the shader to modify the effect while the program is running.

Updated on March 22, 2022 21:53:01pm UTC