PBR opacityTexture shows up as white

Hey, everyone!

I’m having some trouble getting an opacity texture to work with the PBR material. I’ve searched the wiki a bit and I found one property called useAlphaFromAlbedoTexture, but it doesn’t seem to have any effect, so I’m just using material.opacityTexture = new BABYLON.Texture(“media/alphatest.png”) etc. the same as I would for a standard material. Unfortunately the see-through portions of the texture just turn from black to white and there’s no transparency at all. I’ve tried switching the alpha mode as well, and it doesn’t seem to be doing anything either. Here are some screenshots:

And you can see what I’m going for in the bottom picture. It’s a pretty cool technique that’s been around for a while where you’ve got alpha mapped polygons hovering over some non-alpha mapped polygons with a similar texture so you can have furry looking carpets and more realistic looking shrubbery and what not. I definitely recommend messing around with it!

Anyway, I’m exporting it as a GLB with all of the textures packed in with it, however my current node setup isn’t recognized, which is kind of expected since it’s a very…Blender way of handling transparency for lack of a better term :joy:

So my questions are 1. how can I get a PBR material to read its alpha from an opacity texture correctly through code and 2. is there a way for the GLTF exporter to export alpha maps correctly out of the box? I thought I remembered reading somewhere that it has something to do with the transmission property, but I’m not 100% sure.

Here’s a playground I found on the wiki for standard material opacity textures, but I’ve edited it to be a PBR material. 2 of the models turn black and 2 of the models turn completely invisible when switched to a PBR material without any real modifications besides switching “diffuse” to “albedo”

https://www.babylonjs-playground.com/#1MSIXB#11

Any help would be appreciated, and thank you for reading my essay of a question!

Found it!

material.forceAlphaTest = true;


Could use some tweaking still, but I’m liking the direction it’s going! :smile:

Thanks anyway, guys! :ok_hand:

Your tweaked playground will better work like that: https://www.babylonjs-playground.com/#1MSIXB#13 (PBRMat requiered envTexture, and by default their metallic value is 1).

Also, when coming from a glb file, I’ve often have to set transparencyMode to alphablend instead of the default opaque.

1 Like

This is just beautiful!! I want to see it running now :slight_smile:

1 Like

@Vinc3r Ah, transparencyMode not alphaMode, I see! Thank you, I’ll keep that in mind! And yes, metallic can make things pretty dark, I forgot about that too. Even when I was using Unreal 4 I kind of preferred to have metallic at 0.8 instead of 1.0 because it darkened everything so much.

@Deltakosh Thank you, I appreciate it! I’ll be sure to post it in demos and projects when I’m done with it. It shouldn’t be too long, I’m trying to keep the gameplay pretty simple for this one!

1 Like