p5.js loadShader() Method
The function loadShader() loads the shader from files and returns them as a p5 shader object in a variable. The file extension can be .glsl or .shader or .vertex.
It loadShader() should be called from within preload().
loadShader(vertFilename, fragFilename, [callback], [errorCallback])
- vertFilename : It is of string type, and it contains path to the file containing vertex shader source code.
- fragFilename : It is of string type, and it contains path to the file containing fragment shader source code.
- callback : It is a function which is executed after loadShader completes. On success, the Shader object is passed as the first argument. It is optional.
- errorCallback : It is a function which is executed when an error occurs inside loadShader. When there is error then the error is passed as the first argument. It is optional.
A shader object that is created from the provided vertex and fragment shader files.
Example : This example shows how to draw a square with a shader.
My Personal Notes arrow_drop_up
Please Login to comment...