createCanvas(windowWidth, windowHeight, WEBGL);
myShader = createShader(vert, frag);
myShader.setUniform("uTime", millis() / 1000.0);
myShader.setUniform("uResolution", [width, height]);
orbitControl(2, 2, 0.01);
// geometry vertex position provided by p5js.
attribute vec3 aPosition;
// vertex texture coordinate provided by p5js.
attribute vec2 aTexCoord;
// Built in p5.js uniforms
uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
// Varying values passed to our fragment shader
vec4 pos = vec4(aPosition, 1.0);
// Apply the ModelView and Projection matricies
gl_Position = uProjectionMatrix * uModelViewMatrix * pos;
// set the default precision for float variables
uniform vec2 uResolution;
float random(in vec2 _st) {
return fract(sin(dot(_st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
float noise(in vec2 _st) {
// Four corners in 2D of a tile
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
(c - a) * u.y * (1.0 - u.x) +
vec2 shift = vec2(100.0);
// Rotate to reduce axial bias
mat2 rot = mat2(cos(0.5), sin(0.5), -sin(0.5), cos(0.50));
// OpenProcessing.org NOTE: Becuase this shader contains a for loop,
// the Loop Protection feature must be disabled in the sketch editor.
for (int i = 0; i < NUM_OCTAVES; ++i) {
_st = rot * _st * 2.0 + shift;
vec2 st = vVertexPos.xy * 4. + vec2(vVertexPos.z + 1., vVertexPos.z + 1.) * 2.;
q.y = fbm( st + vec2(1.0) );
r.x = fbm( st + 1.0*q + vec2(1.7,9.2) + 0.15*uTime );
r.y = fbm( st + 1.0*q + vec2(8.3,2.8) + 0.226*uTime );
vec3(0.101961,0.619608,0.666667),
vec3(0.666667,0.666667,0.498039),
clamp(length(r.x),0.0,1.0)
// Specify the color for the current pixel.
gl_FragColor = vec4((f*f*f + .6*f*f + .5*f) * color, 1.0);