Closed Themaister closed 5 years ago
We've considered arbitrary texture channel mapping, but it didn't make to the core spec. One of the main obstacles is the lack of native swizzling support in some APIs (e.g. see rationale in WebGL 2.0 spec).
It's still possible to make a glTF extension with such functionality.
/cc @sbtron @bghgary
It is also not supported on GLES2 to my knowledge, so a KHR extension probably makes more sense.
In the short term, swizzling will be partly achievable via KTX2 file format metadata (glTF schema TBD).
Especially PBR metallic roughness has a particular swizzling scheme. It would be desirable to have a way to specify the texture swizzle for images which are loaded. Especially for compressed GPU formats, it might not be possible to efficiently represent PBR textures with G/B swizzle, and R/G two-component formats might be more suitable. Also, single-component compressed textures could be used to represent roughness, while swizzling in 0 or 1 for metallic.
GL maps this to GL_TEXTURE_SWIZZLE_RGBA, and Vulkan maps this in with VkImageView.
I could see an interface looking something like:
Alternatives are placing the swizzle along-side the "source", which means that a texture can only have one swizzle scheme, or as part of the "sampler", which matches more closely to how swizzling works in GL, but would be rather awkward for other APIs.