Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
26 changes: 14 additions & 12 deletions src/webgl/p5.Shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
* }
* </code>
* </div>
Expand All @@ -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;
* }`
* });
* }
Expand Down