I am satisfied that Steel 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 Steel Body Seize appears to substantiate this:
Inspecting the draw…
command’s fragment texture binding:
reveals 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.exchange(…, withBytes: …)
, not MTKTextureLoader
):
Inspecting with Pre-Multiplied Alpha enabled; too mild on the semi-transparent edges to be right:
Inspecting with Pre-Multiplied Alpha enabled; right imagery:
Nevertheless, 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 are actually clearly alpha-premultiplied:
Inspecting with Pre-Multiplied Alpha enabled; right imagery:
Inspecting with Pre-Multiplied Alpha disabled; too darkish on the semi-transparent edges to be right:
So why is Steel doing this? Is that this documented wherever? (I’ve scoured the Steel Shading Language Specification Model 3.1 to no avail.) Is that this configurable by some means? (There is a trace to the aim of this by the argument identify of dataTexture
— I actually want to hold the literal values within the texture except I say in any other case.)
Mixing is being carried out 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 working iPadOS 17.1; and in addition Xcode 15.1 beta 2 with an iPhone 14 Professional iPhone15,2 working iOS 17.2 beta 2.