Setting Array uniform on shader in webgpu?

Hey team! ( @Evgeni_Popov :pray: )

Can we set a floatArray ( float[nb] ) uniform in a way that works on both webgl2 & webGPU?

I’m using the PBRCustomMaterial.
Passing an array causes GPUValidationError when using webGPU.

Simplified example;

I’m having a tough time finding detailed documentation on uniforms, especially the different kinds, sorry if an answer already exists!


this.AddUniform(‘vTestArray’, ‘float[12]’);


this.AddUniform(‘vTestArray[12]’, ‘float’);

seems to fix it?
Is this OK?

If it works then it must be ok :slight_smile: (you are using the PBRCustomMaterial which is not in core, so I don’t really know).

If you use a material plugin or a ShaderMaterial, the method that let’s you define an uniform takes an array size in addition to the size of one element of the array.

1 Like

My biggest concern is if it breaks randomly on different systems.

The GPUValidationError was seemingly from vulkan not liking the way the array was created.

I’ll check out the material plugins, looks very interesting!