opacityTexture & PBRMaterial: can't succeed to make it work

Usually I use alpha from albedoTexture. But I have a case where I must use opacityTexture without having an albedo on my material.

I think I miss a point about how to use it, 'cause my material mock me by staying opaque (l.31):

https://www.babylonjs-playground.com/#9CE5EN#3

Setting the alphaMode property does work:

https://www.babylonjs-playground.com/#9CE5EN#4

On my computer I don’t see the opacityTexture pattern, it should be as this, with white = opaque, red (read as gray value) = middle alpha

The opacity texture is used only to fetch an alpha value in the PBR fragment shader. For the actual texture, you need to use albedoTexture I think.

Also, how can you have an alpha channel by using the amiga texture for the opacity, as this file is a .jpg file? AFAIK, you can’t have an alpha channel in a .jpg file.

Exactly, that’s why I expected the pixel luminance to be taken into account. And of course in that case we don’t care if the texture have an alpha channel.

But, after reading your point, I had the idea to check what the API said about opacityTexture for StandardMaterial, and I get it now, PBRMaterial miss a bit of information ('will fix that): we just need to tell the engine to use the luminance with texture.getAlphaFromRGB = true;

1 Like