Py5Shader

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def setup():
    py5.size(640, 360, py5.P2D)
    global blur
    # shaders files must be in the "data" folder to load correctly
    blur = py5.load_shader("blur.glsl")
    py5.stroke(0, 102, 153)
    py5.rect_mode(py5.CENTER)


def draw():
    py5.apply_filter(blur)
    py5.rect(py5.mouse_x-75, py5.mouse_y, 150, 150)
    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 Java 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 September 16, 2021 14:31:43pm UTC