You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importantly, I modify the position after using it to modify the texture coordinate. I expect the texture to stretch a lot as because the texture coordinates stay the same while the positions they're attached to move. However, the texture remains largely stable in the end result: https://editor.p5js.org/davepagurek/sketches/jCo1EFc07
When I call .inspectHooks(), I can see that the GLSL looks like this:
Instead, we might need to make setting a component replace the whole original node so that references to components from before the modification stay unchanged, and new references after the modification have access to a different, changed value.
The text was updated successfully, but these errors were encountered:
Some more thoughts: If we replace the original node, then we'd likely have to rewrite statements like this:
// Beforeinputs.position.y+=sin(t);// Afterinputs.position=inputs.position.set('y',inputs.position.y+sin(t));// set() returns a new node
Another approach could be to make it so that component nodes own their own value, so that earlier references to inputs.position.y aren't affected by later assignments, as it would replace the y component with a new, different node object.
Most appropriate sub-area of p5.js?
p5.js version
2.0.3
Web browser and version
Firefox
Operating system
MacOS
Steps to reproduce this
I was writing a strands shader that modifies position and also texture coordinates, and uses the position to modify the texture coordinate:
Importantly, I modify the position after using it to modify the texture coordinate. I expect the texture to stretch a lot as because the texture coordinates stay the same while the positions they're attached to move. However, the texture remains largely stable in the end result: https://editor.p5js.org/davepagurek/sketches/jCo1EFc07
When I call
.inspectHooks()
, I can see that the GLSL looks like this:Here we can see that it created the modified position (
temp0
) before using it as an input to the texture coordinates intemp_3
.If I don't assign to a single component of the vector, it works as expected:
I think the issue with assigning to a component is that it currently modifies the original node that
ComponentNode
s reference:p5.js/src/webgl/ShaderGenerator.js
Lines 282 to 290 in 3eae276
Instead, we might need to make setting a component replace the whole original node so that references to components from before the modification stay unchanged, and new references after the modification have access to a different, changed value.
The text was updated successfully, but these errors were encountered: