Anyone has a working playground showing a UniformBuffer?

Hello,
I am just started again working on a project that is using a UniformBuffer. Basically, I am continuing on this project UniformBuffer.addUniform: Arguments unclear with this playground: https://playground.babylonjs.com/#1OH09K#1485

My problem is: The playground is no longer working due to a new AFAIK error message: Cannot add an uniform Array dynamically. Please, add it using addUniform.

I dont remember that I got this error message when I was initially working on this playground, so I wonder what happened in the meantime.

I searched the playground for other examples of UniformBuffer, but none of the playgrounds worked. All of them showed different error messages.

So does anyone has an example that works so I can compare?

Best regards,
Axel

I don’t have any error with this PG in the current Playground (5.0.29).

This PG from UniformBuffer.addUniform: Arguments unclear - #3 by Evgeni_Popov is also working.

I further looked into it and found out that this seems to be a browser issue.
Testing on two Macs, M1 and Intel:

  • Both Chrome v106 and Edge show the problem.
  • Firefox and Safari work fine.

Windows with Chrome seems to work fine.

What combination of browser and OS did you test? Can anyone confirm that this is broken on Mac?

I used Chrome/Firefox (latest versions) on Windows 11.

It’s strange it depends on the browser as the error message is logged by our code in case you update an uniform array without having called addUniform first… In your PG, addUniform for elements is called before the udpateUniformArray call, so it should work unconditionnally and in all browsers…

Uniform buffers are disabled on Chrome for Mac, but eg you can set disableUniformBuffers to false like on line 35 and then the PG works for me on Chrome on my Macbook. :slight_smile: EDIT: but IDK under what conditions the performance might tank… :frowning:

PS just for reference, it’s this PR that disabled uniform buffers for Chrome/Mac. IIRC it was because large GLB models were loading much slower with them enabled. EDIT: here’s the forum thread where it fixed the slow loading issue for reference.

Thank you! Using the provided line to enable the uniform buffers solved my problem. I was just wondering: Can we provide a proper error message? If @Blake didn’t saw this post here, I would probably never found the solution.

Best regards,
Axel

I have updated the error message:

1 Like