Can Texture2D save images with transparent background? Can we use Texture2D with transparent background directly to achieve the effect of transparent image overlaying in Metal shade?

Texture2D can save images with a transparent background. In Texture2D, a separate alpha channel is typically used to describe the transparency of background pixels. In Metal’s fragment shader, colors and alpha values of each pixel can be obtained by sampling the texture, and they can be used for subsequent processing.

Apple iOS

In Metal Shader, how to treat a specific color in texture2d as transparent, for example, white?

In Metal Shader, you can replace the color you want to make transparent by comparing it with a literal color using the texture2d and its sampling coordinates passed to the fragment shader.