demo · v142

Texture component swizzle

Pick a source colour, then remap which input channel feeds each output channel — exactly the semantics of GPUTextureViewDescriptor.componentSwizzle. The right swatch shows the result the shader would see when sampling, computed entirely on the CPU.

source colour:

source texture

after swizzle (shader sees)



    
navigator.gpu present
texture-component-swizzle adapter feature
checking…

relevant API

const view = texture.createView({
  componentSwizzle: { r: "b", g: "g", b: "r", a: "a" } // BGRA
});

see also