regl-project / regl

👑 Functional WebGL
https://regl-project.github.io/
MIT License
5.21k stars 322 forks source link

Array uniforms variable passing bug #611

Open HeGanjie opened 3 years ago

HeGanjie commented 3 years ago

Step

  1. Download the minimal reproduce demo uniform1fv-bug.zip, unzip it. (Thanks to @fuzhenn Source)
  2. Open index.html in chrome.
  3. Open developer console of the browser

Result

Uncaught TypeError: Failed to execute 'uniform1fv' on 'WebGLRenderingContext': Overload resolution failed.
    at draw (eval at compile (regl.js:6018), <anonymous>:343:4)
    at REGLCommand (regl.js:10297)
    at run ((index):74)
    at (index):80

Expected

Correctly handle array uniforms.

mikolalysenko commented 3 years ago

Reverting #591

The automated tests missed this issue.

dionysiusmarquis commented 2 years ago

Ran into the same issue.

Doesn't work: shader: uniform float myArray[2]; command: "myArray[0]": 0.5,

Works: shader: uniform vec2 myArray[2]; command: "myArray[0]": [0.5, 0.0],

thisispete commented 1 year ago

are there any known work-arounds / proposals? I have a project that uses float arrays, the arrays are unknown lengths so the manual unwrap doesn't work well

I use:

uniform float values[32] // max 32 values
uniform int count //pass in the length, I have logic so it only reads the first count values

and would love to just pass uniforms like:

{
  values: [0.0, 1.1, 2.2, 3.3]
  count: 4
}