demo · v143

Normal map fix-up

The use case the swizzle feature was added for: a normal map authored in DirectX convention (Y-down) versus OpenGL convention (Y-up). One line of swizzle config — no shader changes — flips the green channel and reconciles the maps.

source (raw bytes)

sampled with swizzle

the call

// New in v143 — TextureViewDescriptor.swizzle
const view = texture.createView({
  swizzle: {
    r: "r",
    g: "one-minus-g",  // flip Y for OpenGL-style normal map
    b: "b",
    a: "a"
  }
});
// shader code unchanged; sampling already gets the corrected normal

why this angle

The other concept is a knob-twiddler — pick any swizzle. This one shows the canonical reason swizzle was added to WebGPU at all: portability of art assets between engines and conventions. It's the example WGPU spec authors used to justify the feature.

see also