demo · v142

Normal Map Channel Swap

DirectX vs OpenGL normal maps disagree about which channel is Y. Without texture swizzle you'd ship two shader variants or pre-process the texture on the CPU. With swizzle you tell the GPU "sample this texture, but remap the channels at sample time". Swap the dropdowns below to repair a mis-authored normal map without a single texture upload.

source (raw normal map)

swizzled (lit preview)

swizzle

relevant markup

// Chrome 142+: textureViewDescriptor accepts swizzle
const view = texture.createView({
  swizzleR: "r",
  swizzleG: "one",   // pin alpha-like channels
  swizzleB: "b",
  swizzleA: "one"
});

see also