regl icon indicating copy to clipboard operation
regl copied to clipboard

Array uniforms variable passing bug

Open HeGanjie opened this issue 3 years ago • 3 comments

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.

HeGanjie avatar Mar 08 '21 04:03 HeGanjie

Reverting #591

The automated tests missed this issue.

mikolalysenko avatar Mar 10 '21 01:03 mikolalysenko

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],

dionysiusmarquis avatar Nov 17 '21 12:11 dionysiusmarquis

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
}

thisispete avatar Dec 10 '22 18:12 thisispete