Skip to content

Commit 3d9156b

Browse files
committed
filter shader example
1 parent 2655de2 commit 3d9156b

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

preview/global/sketch.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1-
p5.disableFriendlyErrors = true;
1+
// p5.disableFriendlyErrors = true;
22
function windowResized() {
33
resizeCanvas(windowWidth, windowHeight);
44
}
55
let myShader;
6+
let filterShader;
7+
let video;
68

7-
function setup(){
9+
10+
async function setup(){
811
createCanvas(windowWidth, windowHeight, WEBGL);
912

13+
// filterShader = baseFi
14+
15+
filterShader = baseFilterShader().modify(() => {
16+
const time = uniformFloat(() => millis());
17+
18+
getColor((input, canvasContents) => {
19+
let myColor = texture(canvasContents, uvCoords());
20+
const d = distance(input.texCoord, [0.5, 0.5]);
21+
myColor.x = smoothstep(0, 0.5, d);
22+
myColor.y = sin(time*0.001)/2;
23+
return myColor;
24+
})
25+
});
26+
1027
myShader = baseMaterialShader().modify(() => {
1128
const time = uniformFloat(() => millis());
1229

@@ -25,10 +42,12 @@ function setup(){
2542
}
2643

2744
function draw(){
28-
orbitControl();
45+
// orbitControl();
2946
background(0);
30-
shader(myShader);
3147
noStroke();
32-
fill(255,0,0)
33-
sphere(100);
48+
fill('blue')
49+
sphere(100)
50+
shader(myShader);
51+
filter(filterShader);
52+
// filterShader.setUniform('time', millis());
3453
}

0 commit comments

Comments
 (0)