Skip to content

Commit 5db01ea

Browse files
committed
Update more material shader examples
1 parent bdc8310 commit 5db01ea

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/webgl/material.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -1374,14 +1374,12 @@ function material(p5, fn){
13741374
* function setup() {
13751375
* createCanvas(200, 200, WEBGL);
13761376
* myShader = baseMaterialShader().modify({
1377-
* uniforms: {
1378-
* 'float time': () => millis()
1379-
* },
1380-
* 'Vertex getWorldInputs': `(Vertex inputs) {
1377+
* let time = uniformFloat(() => millis());
1378+
* getWorldInputs((inputs) => {
13811379
* inputs.position.y +=
1382-
* 20.0 * sin(time * 0.001 + inputs.position.x * 0.05);
1380+
* 20 * sin(time * 0.001 + inputs.position.x * 0.05);
13831381
* return inputs;
1384-
* }`
1382+
* });
13851383
* });
13861384
* }
13871385
*
@@ -1403,19 +1401,19 @@ function material(p5, fn){
14031401
*
14041402
* function setup() {
14051403
* createCanvas(200, 200, WEBGL);
1406-
* myShader = baseMaterialShader().modify({
1407-
* declarations: 'vec3 myNormal;',
1408-
* 'Inputs getPixelInputs': `(Inputs inputs) {
1404+
* myShader = baseMaterialShader().modify(() => {
1405+
* let myNormal = varyingVec3();
1406+
* getPixelInputs((inputs) => {
14091407
* myNormal = inputs.normal;
14101408
* return inputs;
1411-
* }`,
1412-
* 'vec4 getFinalColor': `(vec4 color) {
1409+
* });
1410+
* getFinalColor((color) => {
14131411
* return mix(
1414-
* vec4(1.0, 1.0, 1.0, 1.0),
1412+
* vec4(1, 1, 1, 1),
14151413
* color,
14161414
* abs(dot(myNormal, vec3(0.0, 0.0, 1.0)))
14171415
* );
1418-
* }`
1416+
* });
14191417
* });
14201418
* }
14211419
*
@@ -1477,10 +1475,10 @@ function material(p5, fn){
14771475
* myShader = baseMaterialShader().modify(() => {
14781476
* getPixelInputs((inputs) => {
14791477
* inputs.normal.x += 0.2 * sin(
1480-
* sin(inputs.texCoord.yx * TWO_PI * [10, 25])
1478+
* sin(TWO_PI * dot(inputs.texCoord.yx, vec2(10, 25)))
14811479
* );
14821480
* inputs.normal.y += 0.2 * sin(
1483-
* sin(inputs.texCoord * TWO_PI * [10, 25])
1481+
* sin(TWO_PI * dot(inputs.texCoord, vec2(10, 25)))
14841482
* );
14851483
* inputs.normal = normalize(inputs.normal);
14861484
* return inputs;

0 commit comments

Comments
 (0)