In this section, we will extend the knowledge of shaders and will see how to pass parameters from your C++ code, how to use Perlin noise, and how to process several images. The examples will be about the fragment shaders, but all the principles extend to the vertex and geometry shaders.
In order to make the shader interactive, we need a way to pass in it some parameters, such as time, mouse position, and some arrays. To add a parameter, you need to add its declaration in the shader's code using the
uniform keyword. For example, to declare the
time parameter, use the following line:
uniform float time;
To specify the parameter's value in openFrameworks, you need to add the following line after the
shader.setUniform1f( "time", time );