@@ -1441,17 +1441,15 @@ function material(p5, fn){
1441
1441
* environment = await loadImage('assets/outdoor_spheremap.jpg');
1442
1442
*
1443
1443
* createCanvas(200, 200, WEBGL);
1444
- * myShader = baseMaterialShader().modify({
1445
- * 'Inputs getPixelInputs': `(Inputs inputs) {
1446
- * float factor =
1447
- * sin(
1448
- * inputs.texCoord.x * ${TWO_PI} +
1449
- * inputs.texCoord.y * ${TWO_PI}
1450
- * ) * 0.4 + 0.5;
1451
- * inputs.shininess = mix(1., 100., factor);
1444
+ * myShader = baseMaterialShader().modify(() => {
1445
+ * getPixelInputs((inputs) => {
1446
+ * let factor = sin(
1447
+ * TWO_PI * (inputs.texCoord.x + inputs.texCoord.y)
1448
+ * );
1449
+ * inputs.shininess = mix(1, 100, factor);
1452
1450
* inputs.metalness = factor;
1453
1451
* return inputs;
1454
- * }`
1452
+ * })
1455
1453
* });
1456
1454
* }
1457
1455
*
@@ -1476,25 +1474,17 @@ function material(p5, fn){
1476
1474
*
1477
1475
* function setup() {
1478
1476
* createCanvas(200, 200, WEBGL);
1479
- * myShader = baseMaterialShader().modify({
1480
- * 'Inputs getPixelInputs': `(Inputs inputs) {
1481
- * vec3 newNormal = inputs.normal;
1482
- * // Simple bump mapping: adjust the normal based on position
1483
- * newNormal.x += 0.2 * sin(
1484
- * sin(
1485
- * inputs.texCoord.y * ${TWO_PI} * 10.0 +
1486
- * inputs.texCoord.x * ${TWO_PI} * 25.0
1487
- * )
1488
- * );
1489
- * newNormal.y += 0.2 * sin(
1490
- * sin(
1491
- * inputs.texCoord.x * ${TWO_PI} * 10.0 +
1492
- * inputs.texCoord.y * ${TWO_PI} * 25.0
1493
- * )
1477
+ * myShader = baseMaterialShader().modify(() => {
1478
+ * getPixelInputs((inputs) => {
1479
+ * inputs.normal.x += 0.2 * sin(
1480
+ * sin(inputs.texCoord.yx * TWO_PI * [10, 25])
1494
1481
* );
1495
- * inputs.normal = normalize(newNormal);
1482
+ * inputs.normal.y += 0.2 * sin(
1483
+ * sin(inputs.texCoord * TWO_PI * [10, 25])
1484
+ * );
1485
+ * inputs.normal = normalize(inputs.normal);
1496
1486
* return inputs;
1497
- * }`
1487
+ * });
1498
1488
* });
1499
1489
* }
1500
1490
*
@@ -1568,18 +1558,13 @@ function material(p5, fn){
1568
1558
* async function setup() {
1569
1559
* img = await loadImage('assets/bricks.jpg');
1570
1560
* createCanvas(100, 100, WEBGL);
1571
- * myShader = baseFilterShader().modify({
1572
- * uniforms: {
1573
- * 'float time': () => millis()
1574
- * },
1575
- * 'vec4 getColor': `(
1576
- * FilterInputs inputs,
1577
- * in sampler2D canvasContent
1578
- * ) {
1561
+ * myShader = baseFilterShader().modify(() => {
1562
+ * let time = uniformFloat(() => millis());
1563
+ * getColor((color, canvasContent) => {
1579
1564
* inputs.texCoord.y +=
1580
- * 0.01 * sin(time * 0.001 + inputs.position.x * 5.0 );
1581
- * return getTexture (canvasContent, inputs.texCoord);
1582
- * }`
1565
+ * 0.01 * sin(time * 0.001 + inputs.position.x * 5);
1566
+ * return texture (canvasContent, inputs.texCoord);
1567
+ * });
1583
1568
* });
1584
1569
* }
1585
1570
*
0 commit comments