# Draw Text Dynamic Texture On PBR Material

**URL:** <https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582>\
**Category:** Questions\
**Tags:** material\
**Created:** [July 17, 2020, 10:44am UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582 "2020-07-17T10:44:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alvin\_Stefanus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alvin_stefanus/32/3774_2.png) [@Alvin\_Stefanus](https://forum.babylonjs.com/u/Alvin_Stefanus)\
**Post date:** [July 17, 2020, 10:44am UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/1 "2020-07-17T10:44:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [July 17, 2020, 12:59pm UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/2 "2020-07-17T12:59:52Z")

</div>

Is this getting close to what you want [https://www.babylonjs-playground.com/#TMHF80#154](https://www.babylonjs-playground.com/#TMHF80#154)?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 17, 2020, 1:00pm UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/3 "2020-07-17T13:00:05Z")

</div>

Make sure you clear the texture with a color having alpha component = 0.

I think a PG would help too.

---

<div class="post-metadata">

**Author:** ![Alvin\_Stefanus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alvin_stefanus/32/3774_2.png) [@Alvin\_Stefanus](https://forum.babylonjs.com/u/Alvin_Stefanus)\
**Post date:** [July 18, 2020, 3:43am UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/4 "2020-07-18T03:43:19Z")

</div>

Thank you @JohnK and @Evgeni_Popov

This is my playground link [writing transparent dynamic texture to pbr material](https://www.babylonjs-playground.com/#7FYWYL#6)

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.

---

<div class="post-metadata">

**Author:** ![Alvin\_Stefanus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alvin_stefanus/32/3774_2.png) [@Alvin\_Stefanus](https://forum.babylonjs.com/u/Alvin_Stefanus)\
**Post date:** [July 18, 2020, 12:42pm UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/5 "2020-07-18T12:42:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [July 18, 2020, 1:18pm UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/6 "2020-07-18T13:18:48Z")

</div>

Likely

```javascript
material.transparencyMode = BABYLON.PBRMaterial.PBRMATERIAL_ALPHABLEND;

```

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 18, 2020, 1:24pm UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/7 "2020-07-18T13:24:53Z")

</div>

Indeed, setting `transparencyMode` does work but you also need to set `useAlphaFromAlbedoTexture` to true:

[https://www.babylonjs-playground.com/#7FYWYL#7](https://www.babylonjs-playground.com/#7FYWYL#7)

---

<div class="post-metadata">

**Author:** ![Caner](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/caner/32/15711_2.png) [@Caner](https://forum.babylonjs.com/u/Caner)\
**Post date:** [February 15, 2025, 1:05am UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/8 "2025-02-15T01:05:19Z")

</div>

Hi! Using the exact same solution on the PG, with my project tree-shaken from 7.49.0, the color does not reflect on the material. If I were to try with StandardMaterial, then background would not be transparent. It is working with 6.39.0.

Do I need to import something else? Or am I missing anything?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 15, 2025, 11:49am UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/9 "2025-02-15T11:49:00Z")

</div>

It’s hard to tell, as [this PG](https://www.babylonjs-playground.com/#7FYWYL#53) still works with 7.49.0. Are you able to repro the problem in the Playground?

---

<div class="post-metadata">

**Author:** ![Caner](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/caner/32/15711_2.png) [@Caner](https://forum.babylonjs.com/u/Caner)\
**Post date:** [February 15, 2025, 12:48pm UTC](https://forum.babylonjs.com/t/draw-text-dynamic-texture-on-pbr-material/12582/10 "2025-02-15T12:48:19Z")

</div>

I would but I don’t know how to reproduce tree-shaking in the Playground. But figured out something else though, when I change the roughness to 1, and metallic to 0. I started to see some results. Also tried to reduce the roughness to 0 in the PG, but it still works there.

Wanted to point out I’m using the same light settings with the PG.

I think I am good to go from this point. Thank you anyways!
