Getting good Alpha from textures

This has been happening forever in STD materials, but now that I am really playing with PBR, I have come to a conclusion that alpha in textures is not really working well for me.

I have a number of meshes, shown here in Blender 2.80, in solid mode.

When in Blender materials mode, edges of the hair & eye browsers look very nice. BTW, they also look like this MakeHuman.

Here is what they look like in PBR in Edge Browser (slightly different from in STD, but not as it relates to alpha)

Here is the code generated for the eyebrowse material (looks the same as when coming from JSON)

material = new BABYLON.PBRMaterial("MH.eyebrow005", scene);
material.backFaceCulling = true;
material.checkReadyOnlyOnce = false;
material.maxSimultaneousLights = 4;
material.environmentIntensity = 1;
material.reflectivityColor = new QI.C(.5,.5,.5);
material.roughness = .5;
material.alpha = 1;
material.transparencyMode = BABYLON.PBRMaterial.PBRMATERIAL_ALPHATEST;
material.metallic = 0;
texture = new BABYLON.Texture(resourcesRootDir + "eyebrow005.png", scene, false, true, BABYLON.Texture.TRILINEAR_SAMPLINGMODE, onTexturesLoaded, onTextureError);
texture.hasAlpha = true;
texture.level = 1;
texture.coordinatesIndex = 0;
texture.coordinatesMode = 0;
texture.uOffset = 0;
texture.vOffset = 0;
texture.uScale = 1;
texture.vScale = 1;
texture.uAng = 0;
texture.vAng = 0;
texture.wAng = 0;
texture.wrapU = 1;
texture.wrapV = 1;
material.albedoTexture = texture;
material.useAlphaFromAlbedoTexture = true;

There is clearly some alpha, but is there anyway this might be improved?

@JCPalmer : Did you try setting the “Transparency Mode” to “Alpha blend” ? See image below. the MH hairbrow file mapped onto a plane , exported and viewed in Sandbox against a white background. Without the change the transparency was very blotchy.

cheers, gryff :slight_smile:


@gryff, thanks. This ties into an earlier question when I was trying to even get export working at all without clipping for textures with alpha.

PBRMATERIAL_ALPHATEST got me the same as STD materials. I now want better. Think I am going to have to go through a 4 modes. I seem to remember PBRMATERIAL_ALPHABLEND did not work right. Think because the exporter is setting everything the same.

May need to add a custom property to the materials section of the exporter to allow setting the transparency mode, or set the material._alphaCutOff, in which case you are screwed in the .babylon exporter cause it is not serialized.

@sebavan, is there a reason alphaCutOff is protected & not serializable?

It actually is, here is the definition:
* Defines the alpha limits in alpha test mode.
public alphaCutOff = 0.4;

1 Like

Ok, I tried setting everything to PBRMATERIAL_ALPHABLEND, and it looked great at certain angles, BUT you sometimes get clipping at other angles & distances.


Everything set to PBRMATERIAL_ALPHATESTANDBLEND looked better than PBRMATERIAL_ALPHATEST, but not as good as PBRMATERIAL_ALPHABLEND. It also had the clipping problem.

Setting the body to PBRMATERIAL_OPAQUE and the hair materials to PBRMATERIAL_ALPHABLEND (below) looked fantastic & no clipping ever. I had avoiding eyelashes on male meshes, because it looked like a mascara screw up, but will have to revisit this soon.

Think I am going to make 2 additional custom exporter properties for both the transparency mode & and cutoff. Defaults will be PBRMATERIAL_OPAQUE & 0.4, respectively. Do not really need cutoff for my needs for MH, but am not doing this a third time. Will not show up in the .babylon exporter right now. Am busy coordinating multiple Blender addins & working my own work flow. Soonish.

Just checking, are there equivalents for STD materials, @sebavan ?

I do not think so, we added those to support gltf in the PBR material.