|
| 1 | +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ |
| 2 | + |
| 3 | +/* |
| 4 | + Part of the Processing project - http://processing.org |
| 5 | +
|
| 6 | + Copyright (c) 2012-21 The Processing Foundation |
| 7 | + Copyright (c) 2004-12 Ben Fry and Casey Reas |
| 8 | + Copyright (c) 2001-04 Massachusetts Institute of Technology |
| 9 | +
|
| 10 | + This library is free software; you can redistribute it and/or |
| 11 | + modify it under the terms of the GNU Lesser General Public |
| 12 | + License as published by the Free Software Foundation, version 2.1. |
| 13 | +
|
| 14 | + This library is distributed in the hope that it will be useful, |
| 15 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | + Lesser General Public License for more details. |
| 18 | +
|
| 19 | + You should have received a copy of the GNU Lesser General |
| 20 | + Public License along with this library; if not, write to the |
| 21 | + Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
| 22 | + Boston, MA 02111-1307 USA |
| 23 | +*/ |
| 24 | + |
| 25 | +package processing.core; |
| 26 | + |
| 27 | +/** |
| 28 | + * This class encapsulates a shader program, including a vertex and a fragment |
| 29 | + * shader. It is the renderer-agnostic type that sketches declare and pass to |
| 30 | + * <b>shader()</b> and <b>filter()</b>; each renderer supplies its own |
| 31 | + * implementation (for example a GLSL-backed shader under P2D/P3D, or a WGSL |
| 32 | + * one under the WebGPU renderer). |
| 33 | + * |
| 34 | + * Use the <b>loadShader()</b> function to load your shader code, rather than |
| 35 | + * constructing a renderer-specific implementation directly. |
| 36 | + * |
| 37 | + * @webref rendering:shaders |
| 38 | + * @webBrief This class encapsulates a shader program, including a vertex and a |
| 39 | + * fragment shader |
| 40 | + */ |
| 41 | +public interface PShader { |
| 42 | + |
| 43 | + /** |
| 44 | + * Sets the uniform variables inside the shader to modify the effect while the |
| 45 | + * program is running. |
| 46 | + * |
| 47 | + * @webref rendering:shaders |
| 48 | + * @webBrief Sets a variable within the shader |
| 49 | + * @param name the name of the uniform variable to modify |
| 50 | + * @param x first component of the variable to modify |
| 51 | + */ |
| 52 | + void set(String name, int x); |
| 53 | + |
| 54 | + /** |
| 55 | + * @param y 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) |
| 56 | + */ |
| 57 | + void set(String name, int x, int y); |
| 58 | + |
| 59 | + /** |
| 60 | + * @param z 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) |
| 61 | + */ |
| 62 | + void set(String name, int x, int y, int z); |
| 63 | + |
| 64 | + /** |
| 65 | + * @param w 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) |
| 66 | + */ |
| 67 | + void set(String name, int x, int y, int z, int w); |
| 68 | + |
| 69 | + void set(String name, float x); |
| 70 | + void set(String name, float x, float y); |
| 71 | + void set(String name, float x, float y, float z); |
| 72 | + void set(String name, float x, float y, float z, float w); |
| 73 | + |
| 74 | + /** |
| 75 | + * @param vec modifies all the components of an array/vector uniform variable. PVector can only be used if the type of the variable is vec3. |
| 76 | + */ |
| 77 | + void set(String name, PVector vec); |
| 78 | + |
| 79 | + void set(String name, boolean x); |
| 80 | + void set(String name, boolean x, boolean y); |
| 81 | + void set(String name, boolean x, boolean y, boolean z); |
| 82 | + void set(String name, boolean x, boolean y, boolean z, boolean w); |
| 83 | + |
| 84 | + void set(String name, int[] vec); |
| 85 | + |
| 86 | + /** |
| 87 | + * @param ncoords number of coordinates per element, max 4 |
| 88 | + */ |
| 89 | + void set(String name, int[] vec, int ncoords); |
| 90 | + |
| 91 | + void set(String name, float[] vec); |
| 92 | + void set(String name, float[] vec, int ncoords); |
| 93 | + |
| 94 | + void set(String name, boolean[] vec); |
| 95 | + void set(String name, boolean[] boolvec, int ncoords); |
| 96 | + |
| 97 | + /** |
| 98 | + * @param mat matrix of values |
| 99 | + */ |
| 100 | + void set(String name, PMatrix2D mat); |
| 101 | + |
| 102 | + void set(String name, PMatrix3D mat); |
| 103 | + |
| 104 | + /** |
| 105 | + * @param use3x3 enforces the matrix is 3 x 3 |
| 106 | + */ |
| 107 | + void set(String name, PMatrix3D mat, boolean use3x3); |
| 108 | + |
| 109 | + /** |
| 110 | + * @param tex sets the sampler uniform variable to read from this image texture |
| 111 | + */ |
| 112 | + void set(String name, PImage tex); |
| 113 | +} |
0 commit comments