-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.3
Web browser and version
Firefox
Operating system
MacOS
Steps to reproduce this
Steps:
- Create a p5.strands shader
- Create a uniform vector with a default value, e.g.
uniformVector2(() => [width, height]) - Use the shader in
draw - Try to run the sketch, and an error will occur
I tried putting a debugger statement after the call and running the sketch with the debugger open. You can see that the array is mistakenly getting wrapped in dynamicNode:
const size = uniformVector2('size', () => dynamicNode([
width,
height
]))We should not wrap arrays in dynamicNode if the array is the callback to a uniform function.
Snippet:
let myShader
function setup() {
createCanvas(400, 400, WEBGL);
myShader = baseMaterialShader().modify(() => {
const size = uniformVector2(() => [width, height])
debugger
getPixelInputs((inputs) => {
inputs.color = [
size / 1000,
0,
1
]
return inputs
})
})
}
function draw() {
background(220)
shader(myShader)
plane(width, height)
}Live: https://editor.p5js.org/davepagurek/sketches/McwMGHEFf