Skip to content

Commit 6770cb9

Browse files
Merge remote-tracking branch 'upstream/dev-2.0' into fix/buildGeometry-docs
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents eb2d0d2 + 666c425 commit 6770cb9

File tree

12 files changed

+105
-86
lines changed

12 files changed

+105
-86
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test/**/*.js": "eslint",
2121
"utils/**/*.{js,mjs}": "eslint"
2222
},
23-
"version": "2.2.3-rc.0",
23+
"version": "2.2.3-rc.1",
2424
"dependencies": {
2525
"@davepagurek/bezier-path": "^0.0.7",
2626
"@japont/unicode-range": "^1.0.0",

src/strands/p5.strands.js

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function strands(p5, fn) {
4141
ctx.vertexDeclarations = new Set();
4242
ctx.fragmentDeclarations = new Set();
4343
ctx.hooks = [];
44-
ctx.globalAssignments = [];
4544
ctx.backend = backend;
4645
ctx.active = active;
4746
ctx.renderer = renderer;
@@ -63,7 +62,6 @@ function strands(p5, fn) {
6362
ctx.vertexDeclarations = new Set();
6463
ctx.fragmentDeclarations = new Set();
6564
ctx.hooks = [];
66-
ctx.globalAssignments = [];
6765
ctx.active = false;
6866
p5.disableFriendlyErrors = ctx.previousFES;
6967
for (const key in ctx.windowOverrides) {
@@ -212,7 +210,7 @@ if (typeof p5 !== "undefined") {
212210
* }
213211
*
214212
* function material() {
215-
* let t = uniformFloat();
213+
* let t = millis();
216214
* worldInputs.begin();
217215
* // Move the vertex up and down in a wave in world space
218216
* // In world space, moving the object (e.g., with translate()) will affect these coordinates
@@ -224,7 +222,6 @@ if (typeof p5 !== "undefined") {
224222
* function draw() {
225223
* background(255);
226224
* shader(myShader);
227-
* myShader.setUniform('t', millis());
228225
* lights();
229226
* noStroke();
230227
* fill('red');
@@ -313,9 +310,7 @@ if (typeof p5 !== "undefined") {
313310
* A value between `0.0` and `1.0`
314311
*
315312
* @example
316-
* <div modernizr="webgl">
317-
* <code>
318-
* // Example 1: A soft vertical fade using smoothstep (no uniforms)
313+
* // Example 1: A soft vertical fade using smoothstep
319314
*
320315
* let fadeShader;
321316
*
@@ -334,31 +329,25 @@ if (typeof p5 !== "undefined") {
334329
*
335330
* function setup() {
336331
* createCanvas(300, 200, WEBGL);
337-
* fadeShader = baseFilterShader().modify(fadeCallback);
332+
* fadeShader = buildFilterShader(fadeCallback);
338333
* }
339334
*
340335
* function draw() {
341336
* background(0);
342337
* filter(fadeShader);
343338
* }
344-
* </code>
345-
* </div>
346339
*
347340
* @example
348-
* <div modernizr="webgl">
349-
* <code>
350-
* // Example 2: Animate the smooth transition using a uniform
341+
* // Example 2: Animate the smooth transition over time
351342
*
352343
* let animatedShader;
353344
*
354345
* function animatedFadeCallback() {
355-
* const time = uniformFloat(() => millis() * 0.001);
356-
*
357346
* getColor((inputs) => {
358347
* let x = inputs.texCoord.x;
359348
*
360349
* // Move the smoothstep band back and forth over time
361-
* let center = 0.5 + 0.25 * sin(time);
350+
* let center = 0.5 + 0.25 * sin(millis() * 0.001);
362351
* let t = smoothstep(center - 0.05, center + 0.05, x);
363352
*
364353
* return [t, t, t, 1];
@@ -367,15 +356,13 @@ if (typeof p5 !== "undefined") {
367356
*
368357
* function setup() {
369358
* createCanvas(300, 200, WEBGL);
370-
* animatedShader = baseFilterShader().modify(animatedFadeCallback);
359+
* animatedShader = buildFilterShader(animatedFadeCallback);
371360
* }
372361
*
373362
* function draw() {
374363
* background(0);
375364
* filter(animatedShader);
376365
* }
377-
* </code>
378-
* </div>
379366
*/
380367

381368
/**
@@ -492,7 +479,7 @@ if (typeof p5 !== "undefined") {
492479
* }
493480
*
494481
* function material() {
495-
* let t = uniformFloat();
482+
* let t = millis();
496483
* pixelInputs.begin();
497484
* // Animate alpha (transparency) based on x position
498485
* pixelInputs.color.a = 0.5 + 0.5 *
@@ -503,7 +490,6 @@ if (typeof p5 !== "undefined") {
503490
* function draw() {
504491
* background(240);
505492
* shader(myShader);
506-
* myShader.setUniform('t', millis());
507493
* lights();
508494
* noStroke();
509495
* fill('purple');
@@ -694,7 +680,7 @@ if (typeof p5 !== "undefined") {
694680
* }
695681
*
696682
* function material() {
697-
* let t = uniformFloat();
683+
* let t = millis();
698684
* objectInputs.begin();
699685
* // Create a sine wave along the object
700686
* objectInputs.position.y += sin(t * 0.001 + objectInputs.position.x);
@@ -704,7 +690,6 @@ if (typeof p5 !== "undefined") {
704690
* function draw() {
705691
* background(220);
706692
* shader(myShader);
707-
* myShader.setUniform('t', millis());
708693
* noStroke();
709694
* fill('orange');
710695
* sphere(50);
@@ -736,7 +721,7 @@ if (typeof p5 !== "undefined") {
736721
* }
737722
*
738723
* function material() {
739-
* let t = uniformFloat();
724+
* let t = millis();
740725
* cameraInputs.begin();
741726
* // Move vertices in camera space based on their x position
742727
* cameraInputs.position.y += 30 * sin(cameraInputs.position.x * 0.05 + t * 0.001);
@@ -748,7 +733,6 @@ if (typeof p5 !== "undefined") {
748733
* function draw() {
749734
* background(200);
750735
* shader(myShader);
751-
* myShader.setUniform('t', millis());
752736
* noStroke();
753737
* fill('red');
754738
* sphere(50);
@@ -795,8 +779,6 @@ if (typeof p5 !== "undefined") {
795779
* will behave as a vec4 holding components r, g, b, and a (alpha), with each component being in the range 0.0 to 1.0.
796780
*
797781
* @example
798-
* <div modernizr='webgl'>
799-
* <code>
800782
* // A filter shader (using p5.strands) which will
801783
* // sample and invert the color of each pixel
802784
* // from the canvas.
@@ -829,12 +811,8 @@ if (typeof p5 !== "undefined") {
829811
*
830812
* filterColor.end();
831813
* }
832-
* </code>
833-
*
834814
*
835815
* @example
836-
* <div modernizr='webgl'>
837-
* <code>
838816
* // This primitive edge-detection filter samples
839817
* // and compares the colors of the current pixel
840818
* // on the canvas, and a little to the right.
@@ -891,8 +869,6 @@ if (typeof p5 !== "undefined") {
891869
* rotate(frameCount / 300);
892870
* square(0, 0, 30);
893871
* }
894-
* </code>
895-
* </div>
896872
*/
897873

898874
/**

src/strands/strands_api.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
427427
typeInfo,
428428
usedInVertex: false,
429429
usedInFragment: false,
430-
declared: false
431430
});
432431

433432
return createStrandsNode(id, dimension, strandsContext);

src/strands/strands_codegen.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ export function generateShaderCode(strandsContext) {
4747
backend.generateBlock(blockID, strandsContext, generationContext);
4848
}
4949

50-
// Process any unvisited global assignments to ensure side effects are generated
51-
for (const assignmentNodeID of strandsContext.globalAssignments) {
52-
if (!generationContext.visitedNodes.has(assignmentNodeID)) {
53-
// This assignment hasn't been visited yet, so we need to generate it
54-
backend.generateAssignment(generationContext, strandsContext.dag, assignmentNodeID);
55-
generationContext.visitedNodes.add(assignmentNodeID);
56-
}
57-
}
58-
59-
// Reset global assignments for next hook
60-
strandsContext.globalAssignments = [];
61-
6250
const firstLine = backend.hookEntry(hookType);
6351
let returnType;
6452
if (hookType.returnType.properties) {

src/strands/strands_node.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ export class StrandsNode {
6969
const assignmentID = getOrCreateNode(dag, assignmentNode);
7070
recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
7171

72-
// Track for global assignments processing
73-
this.strandsContext.globalAssignments.push(assignmentID);
74-
7572
// Simply update this node to be a variable node with the identifier
7673
// This ensures it always generates the variable name in expressions
7774
const variableNodeData = createNodeData({
@@ -135,9 +132,6 @@ export class StrandsNode {
135132
const assignmentID = getOrCreateNode(dag, assignmentNode);
136133
recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
137134

138-
// Track for global assignments processing in the current hook context
139-
this.strandsContext.globalAssignments.push(assignmentID);
140-
141135
// Simply update this node to be a variable node with the identifier
142136
// This ensures it always generates the variable name in expressions
143137
const variableNodeData = createNodeData({

0 commit comments

Comments
 (0)