diff --git a/src/webgl/material.js b/src/webgl/material.js index 718a85740e..2a3a7898df 100644 --- a/src/webgl/material.js +++ b/src/webgl/material.js @@ -2116,7 +2116,7 @@ function material(p5, fn){ * * function draw() { * background(255); - * shader(myShader); + * strokeShader(myShader); * strokeWeight(10); * beginShape(); * for (let i = 0; i <= 50; i++) { diff --git a/src/webgl/p5.Shader.js b/src/webgl/p5.Shader.js index 0d45dd679f..be8520bc85 100644 --- a/src/webgl/p5.Shader.js +++ b/src/webgl/p5.Shader.js @@ -316,22 +316,23 @@ class Shader { * createCanvas(200, 200, WEBGL); * myShader = baseMaterialShader().modify({ * uniforms: { - * 'float time': () => millis() + * 'float time': () => millis() // Uniform for time * }, - * 'vec3 getWorldPosition': `(vec3 pos) { - * pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); - * return pos; + * 'Vertex getWorldInputs': `(Vertex inputs) { + * inputs.position.y += + * 20. * sin(time * 0.001 + inputs.position.x * 0.05); + * return inputs; * }` * }); * } * * function draw() { * background(255); - * shader(myShader); - * lights(); - * noStroke(); - * fill('red'); - * sphere(50); + * shader(myShader); // Apply the custom shader + * lights(); // Enable lighting + * noStroke(); // Disable stroke + * fill('red'); // Set fill color to red + * sphere(50); // Draw a sphere with the shader applied * } * * @@ -346,9 +347,10 @@ class Shader { * myShader = baseMaterialShader().modify({ * // Manually specifying a uniform * declarations: 'uniform float time;', - * 'vec3 getWorldPosition': `(vec3 pos) { - * pos.y += 20. * sin(time * 0.001 + pos.x * 0.05); - * return pos; + * 'Vertex getWorldInputs': `(Vertex inputs) { + * inputs.position.y += + * 20. * sin(time * 0.001 + inputs.position.x * 0.05); + * return inputs; * }` * }); * }