Search code examples
textureswebgpu

WebGPU: change texture at runtime


I know how to change matrices using queue.writeBuffer. But what is the correct/recommend way to switch textures or samplers inside the rendering loop? Or do I need one pipeline per texture?

thx in advance


Solution

  • No need for a pipeline per texture. You can use different BindGroups, each with a different texture bound.

    If the textures you are switching between are the same size and format, you can also bind a texture array containing the images and use a shader uniform to select the array slice.