I am satisfied that Metallic is alpha-premultiplying my texture in some unspecified time in the future between the attachment
commandEncoder.setFragmentTexture(…, index: 0) and the fragment shader’s arguments (
texture2d<float> texture [[texture(0)]],). The Xcode Metallic Body Seize appears to substantiate this:
draw… command’s fragment texture binding:
exhibits that is clearly a non-alpha-premultiplied picture (which I do know to be true of the
CGImage it comes from— it is pulled from the community and is loaded manually with
texture.substitute(…, withBytes: …), not
Nonetheless, when debugging the identical texel as returned by the
dataTexture.pattern(dataTextureSampler, in.dataTextureCoordinate) name within the fragment shader (utilizing the
0 texture fragment binding), the pixels at the moment are clearly alpha-premultiplied:
So why is Metallic doing this? Is that this documented anyplace? (I’ve scoured the Metallic Shading Language Specification Model 3.1 to no avail.) Is that this configurable in some way? (There is a trace to the aim of this by the argument title of
dataTexture— I actually want to preserve the literal values within the texture except I say in any other case.)
Mixing is being finished with RGB: add, one, oneMinusSourceAlpha; A: add, one, oneMinusSourceAlpha; as is customary for pre-multiplied alpha mixing (although I am fairly positive that is not related right here since we’re fragment inputs, not blended outputs).
Utilizing Xcode 15.0.1 with an iPad Professional 11″ 2021 iPad13,6 operating iPadOS 17.1; and likewise Xcode 15.1 beta 2 with an iPhone 14 Professional iPhone15,2 operating iOS 17.2 beta 2.