Skip to content

Commit b8072f9

Browse files
committed
sketch example
1 parent 98a78a7 commit b8072f9

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

preview/global/sketch.js

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let myShader;
22
let myShader2;
3+
34
p5.disableFriendlyErrors = true;
45
function windowResized() {
56
resizeCanvas(windowWidth, windowHeight);
@@ -8,50 +9,51 @@ function calculateOffset() {
89
return 30;
910
}
1011

12+
function myCol() {
13+
const col = (sin(millis() * 0.001) + 1)/2;
14+
return col;
15+
}
16+
1117
function setup(){
1218
createCanvas(windowWidth, windowHeight, WEBGL);
13-
// // Raw example
19+
1420
myShader = baseMaterialShader().modify(() => {
15-
const uCol = uniformVector4(0.1,0.1,0.1,1);
16-
const time = uniformFloat(()=>millis);
17-
getFinalColor((col) => {
18-
let x = createFloat(0.5);
19-
col.x = createFloat(time);
20-
col.w = 1;
21-
col /= uCol;
22-
return col;
21+
const uCol = uniformVector4(1,0, 0,1);
22+
const time = uniformFloat(() => millis());
23+
getFinalColor((color) => {
24+
color = uCol;
25+
color.y = 1;
26+
let x = createVector4(time);
27+
x.x += createFloat(2);
28+
color += x;
29+
return color;
2330
});
31+
// getWorldInputs((Inputs) => {
32+
// console.log(Inputs)
33+
// })
2434
}, { parser: true, srcLocations: true });
25-
26-
console.log(myShader)
27-
// Create and use the custom shader.
28-
// myShader2 = baseMaterialShader().modify(
29-
// () => {
30-
// // const offset = uniformFloat('offset', 1)
31-
32-
// getFinalColor((pos) => {
33-
// let a = createVector4(1, 2, 3);
34-
// let b = createVector4(3, 4, 5);
35-
// a = a.add(b);
36-
37-
// let c = a.add(b);
38-
// // c += c.add(offset);
39-
// // c.x = b.x.add(1);
40-
41-
// pos = pos.add(c);
42-
43-
// return pos;
44-
// })
45-
// }, { parser: false, srcLocations: true });
4635
}
4736

4837
function draw(){
49-
// Set the styles
5038
background(0);
51-
// fill(0)
5239
shader(myShader);
53-
stroke('red')
54-
fill(255,0,0)
55-
// myShader.setUniform('uCol', [0.1,2,0,1])
40+
fill(0,0,0)
5641
sphere(100);
5742
}
43+
44+
`(vec4 color) {
45+
// From at <computed> [as uniformVector4] (http://localhost:5173/p5.js:86002:25)
46+
vec4 temp_0 = uCol;
47+
temp_0 = vec4(temp_0.x, 1.0000, temp_0.z, temp_0.w);
48+
vec4 finalReturnValue = temp_0;
49+
return finalReturnValue;
50+
}`
51+
`
52+
(vec4 color) {
53+
54+
// From at <computed> [as uniformVector4] (http://localhost:5173/p5.js:86002:25)
55+
vec4 temp_0 = uCol;
56+
temp_0 = vec4(temp_0.x, 1.0000, temp_0.z, temp_0.w);
57+
vec4 finalReturnValue = temp_0 + vec4(0.0000 + 2.0000, 0.0000, 0.0000, 0.0000);
58+
return finalReturnValue;
59+
}`

0 commit comments

Comments
 (0)