1
1
let myShader ;
2
2
let myShader2 ;
3
+
3
4
p5 . disableFriendlyErrors = true ;
4
5
function windowResized ( ) {
5
6
resizeCanvas ( windowWidth , windowHeight ) ;
@@ -8,50 +9,51 @@ function calculateOffset() {
8
9
return 30 ;
9
10
}
10
11
12
+ function myCol ( ) {
13
+ const col = ( sin ( millis ( ) * 0.001 ) + 1 ) / 2 ;
14
+ return col ;
15
+ }
16
+
11
17
function setup ( ) {
12
18
createCanvas ( windowWidth , windowHeight , WEBGL ) ;
13
- // // Raw example
19
+
14
20
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 ;
23
30
} ) ;
31
+ // getWorldInputs((Inputs) => {
32
+ // console.log(Inputs)
33
+ // })
24
34
} , { 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 });
46
35
}
47
36
48
37
function draw ( ) {
49
- // Set the styles
50
38
background ( 0 ) ;
51
- // fill(0)
52
39
shader ( myShader ) ;
53
- stroke ( 'red' )
54
- fill ( 255 , 0 , 0 )
55
- // myShader.setUniform('uCol', [0.1,2,0,1])
40
+ fill ( 0 , 0 , 0 )
56
41
sphere ( 100 ) ;
57
42
}
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