Hello,
I am currently porting a scientific application from WebGL to WebGPU:
A simulation of an ultrasound phased array, for the ones interested:
After finding out that I can continue using GLSL as a shading language, I try to touch these later, after get most of the stuff running.
I am currently struggling getting a Uniform Buffer up and running. Because I am working for a while on this, I do already have a playground that more or less isolates the problem:
(from UniformBuffer.addUniform: Arguments unclear)
https://playground.babylonjs.com/#1OH09K#1096
It shows a cube that is rendered using a custom material that consumes a Uniform Buffer. When switching this playground to WebGPU, I get the following error:
glslang.js:34 ERROR: 0:20: 'binding' : uniform/buffer blocks require layout(binding=X)
I tried modifying the playground to:
- Add a
binding=1
to the layout qualifier of the UBO declaration in the shader. - Add
shaderMaterial.getEffect().bindUniformBlock('myBuffer', 1)
Looks like this is not enough. I get other cryptic error messages.
Does anyone know how to fix it and make the playground work or is there a playground with a working example of a UBO working with WebGPU?
Bonus question: Is a UBO still state of the art? I see that they are disabled by default on Mac and I remember from the desktop days that there is “Shader Storage Buffers”. Any comments on this?
Best regards and thanks to everyone,
Axel