Skip to content

Commit a0199d0

Browse files
committed
dev sketch
1 parent b473ac8 commit a0199d0

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

preview/global/sketch.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,57 @@
11
let myShader;
2+
let myShader2;
23
p5.disableFriendlyErrors = true;
3-
4+
function windowResized() {
5+
resizeCanvas(windowWidth, windowHeight);
6+
}
47
function calculateOffset() {
58
return 30;
69
}
710

811
function setup(){
912
createCanvas(windowWidth, windowHeight, WEBGL);
10-
1113
// // Raw example
1214
myShader = baseMaterialShader().modify(() => {
13-
14-
const offset = uniformFloat(1);
15-
15+
const uCol = uniformVector4(0.1,0.1,0.1,1);
16+
const time = uniformFloat(()=>millis);
1617
getFinalColor((col) => {
17-
let a = createVector4(1, 2, 3, 4);
18-
let b = createVector4(3, 4, 5, 6);
19-
a = (a * b + offset) / 10;
20-
col += a;
18+
let x = createFloat(0.5);
19+
col.x = createFloat(time);
20+
col.w = 1;
21+
col /= uCol;
2122
return col;
2223
});
23-
});
24-
24+
}, { parser: true, srcLocations: true });
2525

26+
console.log(myShader)
2627
// Create and use the custom shader.
27-
// myShader = baseMaterialShader().modify(
28+
// myShader2 = baseMaterialShader().modify(
2829
// () => {
29-
// const offset = uniformFloat('offset', () => calculateOffset)
30+
// // const offset = uniformFloat('offset', 1)
3031

31-
// getWorldPosition((pos) => {
32-
// let a = createVector3(1, 2, 3);
33-
// let b = createVector3(3, 4, 5);
32+
// getFinalColor((pos) => {
33+
// let a = createVector4(1, 2, 3);
34+
// let b = createVector4(3, 4, 5);
3435
// a = a.add(b);
3536

3637
// let c = a.add(b);
37-
// c += c.add(offset);
38-
// c.x = b.x.add(1);
39-
38+
// // c += c.add(offset);
39+
// // c.x = b.x.add(1);
4040

4141
// pos = pos.add(c);
4242

4343
// return pos;
4444
// })
45-
// }
46-
// );
45+
// }, { parser: false, srcLocations: true });
4746
}
4847

4948
function draw(){
5049
// Set the styles
51-
background(0)
50+
background(0);
51+
// fill(0)
52+
shader(myShader);
53+
stroke('red')
54+
fill(255,0,0)
55+
// myShader.setUniform('uCol', [0.1,2,0,1])
56+
sphere(100);
5257
}

0 commit comments

Comments
 (0)