Using an alpha texture to control transparency

v4.2.1

Hello! Oftentimes textures will have a dedicated black-and-white image for controlling a material’s transparency, rather than using the alpha channel of the base color texture.
The nearest way I could think of doing this in Godot would be using a texture to control the Transparency property of a GeometryInstance3D. It doesn’t have to be this property specifically, but the general result should be controlling the object’s transparency with a texture independent of its main color.
How could this be done?

If you’re talking about controlling the alpha of the entire object then the transparency property on the mesh instance would probably be your best bet. If you just want finer control then yeah typically the alpha channel of a texture is used but you could really use any channel of any texture if you made your own shader.

Is controlling the transparency property via a texture possible?

You could if you read the texture manually through a script but that’s probably not the best way. The transparency property is just a single value while a texture holds way more info. I can’t think of a use case for that setup but depends on what you need

Historically, this made sense to use when using ETC1 texture compression (which can’t store an alpha channel), but now that Godot 4 only relies on S3TC/BPTC/ETC2/ASTC (all of which support an alpha channel), it doesn’t make much sense anymore.