I’ve found that alpha test transparency mode (cutout) doesn’t work with an opacityTexture, instead the areas that should be transparent are solid white.
alpha blend transparency works with the same opacityTexture, and alpha test transparency works when the diffuseTexture contains the alpha channel.
Yup it currently in PBR can not be used from the OpacityTexture which is meant to only control blending. This basically improves perf and memory by relying only on one sampler. Is that an issue for you ?
Thanks, that’s an interesting little gotcha as alphablend mode doesn’t require this to be set and technically the albedo texture doesn’t have an alpha channel. Is there a way to make this more friendly?
Isn’t it safe to assume that we will be using some form of alpha blending if an opacity texture is set? It seems like it should automatically enable all required alpha settings when an opacity texture is used as it feels a bit wrong to have to enable a non-existent alpha channel on the albedo texture just for alphatest mode.
Alpha blending is a single parameter that applies as a whole at the end of the rendering to mix the new color with the existing pixel color. On the contrary, alpha testing is something done at the texture level and would have to be enabled on a per texture level: albedo and opacity (and possibly other textures too, if you want to be even more general). To avoid having a setting per texture (and a test per texture), it is enabled at the albedo level but the test itself is done after the alpha value is computed from the albedo + opacity texture, it is not just done from the albedo texture. Maybe having the alpha setting on the albedo texture is a bit unfortunate but it’s still more natural/performant to have it here than on the opacity texture (you generally have already an albedo texture for your material, so if you want alpha testing just add an alpha channel to this texture versus adding a new texture (opacity) just for the alpha channel). Also, having it on the texture and not on the material as a whole let’s the ability later to have a different setting for the albedo and opacity textures, should the need arises.
Right now being able to separate the alpha channel from the albedo texture is very useful for filesize optimization - high resolution photographic PNG files are huge, basis textures don’t support alpha channel on all platforms (especially mobile) and ktx textures for some platforms are still very big.
Being able to apply a separate alpha channel means jpeg / basis compression can be used for cutout textures on all platforms.
I’ve gone ahead and submitted a pull request with a fix that enables alpha cutout if an opacity texture is present, it actually works perfectly without any diffuse/albedo texture at all which is nice.