Skip to content

Commit 01ef185

Browse files
committed
example sketch
1 parent 926f79f commit 01ef185

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

preview/global/sketch.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
let myShader;
2-
3-
let myShader2;
41
p5.disableFriendlyErrors = true;
52
function windowResized() {
63
resizeCanvas(windowWidth, windowHeight);
74
}
8-
function calculateOffset() {
9-
return 30;
10-
}
5+
6+
let myShader;
117

128
function myCol() {
139
const col = (sin(millis() * 0.001) + 1)/2;
@@ -16,25 +12,42 @@ function myCol() {
1612

1713
function setup(){
1814
createCanvas(windowWidth, windowHeight, WEBGL);
19-
2015
myShader = baseMaterialShader().modify(() => {
21-
22-
const offset = uniformFloat(1);
23-
16+
const time = uniformFloat(() => sin(millis()*0.001));
2417
getFinalColor((col) => {
25-
let a = createVector4(1, 2, 3, 4);
26-
let b = createVector4(3, 4, 5, 6);
27-
a = (a * b + offset) / 10;
28-
col += a;
18+
col.x = uvCoords().x;
19+
col.y = uvCoords().y;
2920
return col;
3021
});
31-
// getWorldInputs((Inputs) => {
32-
// console.log(Inputs)
33-
// })
34-
}, { parser: true, srcLocations: true });
22+
getWorldInputs((inputs) => {
23+
inputs.position.x += time * inputs.position.y;
24+
return inputs;
25+
})
26+
}, { parser: true, srcLocations: false });
3527
}
3628

3729
function draw(){
38-
// Set the styles
39-
background(0)
30+
orbitControl();
31+
background(0);
32+
shader(myShader);
33+
noStroke();
34+
fill(255,0,0)
35+
sphere(100);
4036
}
37+
38+
// `(vec4 color) {
39+
// // From at <computed> [as uniformVector4] (http://localhost:5173/p5.js:86002:25)
40+
// vec4 temp_0 = uCol;
41+
// temp_0 = vec4(temp_0.x, 1.0000, temp_0.z, temp_0.w);
42+
// vec4 finalReturnValue = temp_0;
43+
// return finalReturnValue;
44+
// }`
45+
// `
46+
// (vec4 color) {
47+
48+
// // From at <computed> [as uniformVector4] (http://localhost:5173/p5.js:86002:25)
49+
// vec4 temp_0 = uCol;
50+
// temp_0 = vec4(temp_0.x, 1.0000, temp_0.z, temp_0.w);
51+
// vec4 finalReturnValue = temp_0 + vec4(0.0000 + 2.0000, 0.0000, 0.0000, 0.0000);
52+
// return finalReturnValue;
53+
// }`

0 commit comments

Comments
 (0)