So I want to drawText() on a pbr material. The way I do it right now is create Dynamic Texture, the do context.drawText() then I assign the dynamic texture to the PBR material’s Albedo Texture.
The problem is that, the background of the dynamic texture is Black.
I set the:
texture.hasAlpha = true;
material.useAlphaFromAlbedoTexture = true;
texture.drawText(text, left, top, drawFont, style.fontColor, "transparent", true, true);
But it seems that the dynamic texture does not use alpha. So I cannot set it to alpha = 0;
How can I make the background transparent and the text solid colored?
Make sure you clear the texture with a color having alpha component = 0.
I think a PG would help too.
Thank you @JohnK and @Evgeni_Popov
This is my playground link writing transparent dynamic texture to pbr material
I suppose the:
tex.drawText('TEXT', null, null, font, '#f54242', 'transparent', true, true);
will overwrite the material background color. If it is working then, it must be something that is black colored overlay my material color.
Please someone advise.
I just realized that turning the Blend Mode into Alpha Blend from blender fix this issue. I wonder what has changed in the material properties which makes this works?
Can I replicate the alpha blend by setting it from babylon js code?
material.transparencyMode = BABYLON.PBRMaterial.PBRMATERIAL_ALPHABLEND;
transparencyMode does work but you also need to set
useAlphaFromAlbedoTexture to true: