How to set a separate alpha/opacity texture?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bananasam

Hi, is there a way to use a separate texture for the alpha value in a StandardMaterial3D?

It sounds like you can use the 4th channel of the albedo texture but the asset I have provides a separate texture and I don’t see a way to specify that in the Albedo or Transparency (or any other) properties.

I can workaround this by making a custom shader but this seems like a relatively common practice when using third party assets so it would be great if it didn’t require resorting to manually writing shaders.

:bust_in_silhouette: Reply From: rossunger

It seems like a pretty basic shader to write?

As far as I know Godot doesn’t have this built in, but you can create a standardMaterial and then right click on it, and convertToShaderMaterial which will give you the code for that, and then you can just add another texture parameter.

Realistically, you shouldn’t be using separate textures for alpha because it’s wasteful in terms of resources… if it were me I would use some image editing software to combine your albedos with your alpha texture, so that you’re not loading 2 textures into memory for each material.

Thanks for the info. Indeed it isn’t hard to write especially with the convert to shader material option, however this approach doesn’t scale well. And I agree it’s not ideal to have a separate texture for alpha, like I said these are third party assets.

Sounds like I’ll just have to deal with it or figure out a way to automate it

bananasam | 2022-12-21 18:16

:bust_in_silhouette: Reply From: Wakatta

Can’t exactly remember but it has something to do with the Detail property.
Maybe it was the mask or Blend mode or Albedo that needs to be change/set.

Apologies for my fuzzy memory but it’s something to do with that

Hmm I tried playing with the options and it almost worked. In the detail property I tried setting the mask as the opacity texture, the albedo as my base color texture, and then removed the base color texture from the regular albedo texture slot. It applies the color to the correct part of the mesh but unfortunately it just applies the albedo, not the transparency.

I might have to keep playing with it though, thanks!

bananasam | 2022-12-21 18:18