PShader

本参考资料用于Processing 3.0+。 如果你使用的是前一版本,请在使用软件帮助菜单内的参考资料。. 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.

名称

PShader

示例
 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);


  } 
描述 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 loadShader() function to load your shader code. [Note: It’s strongly encouraged to use loadShader() to create a PShader object, rather than calling the PShader constructor manually.]
Methods
set() Sets a variable within the shader
Constructor
PShader() PShader(parent) PShader(parent, vertFilename, fragFilename) PShader(parent, vertURL, fragURL) PShader(parent, vertSource, fragSource) 
参数
parent PApplet: the parent program
vertFilename String: name of the vertex shader
fragFilename String: name of the fragment shader
vertURL URL: network location of the vertex shader
fragURL URL: network location of the fragment shader

Updated on October 2, 2018 05:02:13pm EDT

PShader