WebGPU Shader Uniform Error

Yo @Deltakosh or @sebavan

I have made a shader that to Highlight an instance mesh. The WebGL2 version works great but the the WGSL version gives a error that overlayColor and overlayAlpha are not defined. Even thow
i return them in getUniforms and update them in bind sub meshes. Plus. it works for WebGL2 … something is wrong in my system for the WGSL version.

please take a look:

// WebGL2 - Playground - Babylon.js Playground

// WebGPU - Playground - Babylon.js Playground

In WebGPU, the uniform variables are accessed thanks to a specific structure named uniforms. So, you must access them by doing uniforms.myUniform. Also, you don’t have to declare the uniforms yourself, it will be done automatically by the framework (same thing for WebGL):

See Babylon.js docs for more information.

1 Like

Thanks @Evgeni_Popov