# Decals are not supported for glb files

**URL:** <https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571>\
**Category:** Questions\
**Tags:** material\
**Created:** [October 7, 2022, 11:34am UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571 "2022-10-07T11:34:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vijay\_krishna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vijay_krishna/32/18667_2.png) [@vijay\_krishna](https://forum.babylonjs.com/u/vijay_krishna)\
**Post date:** [October 7, 2022, 11:34am UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/1 "2022-10-07T11:34:11Z")

</div>

Hi,

We are trying apply decals on tshirts(.glb file) its not working. It seems only. babylon files are supported.  
We are stuck from last few days… pls suggest the way forward

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#EEUVTY%23135)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

glb file used  
[https://raw.githubusercontent.com/myinzack/Riggedavatars/main/tshirt\_walking.glb](https://raw.githubusercontent.com/myinzack/Riggedavatars/main/tshirt_walking.glb)

Thanks  
vijay

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 7, 2022, 12:09pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/2 "2022-10-07T12:09:07Z")

</div>

Decals are supported for all types of imported meshes, including GLB, as you can see here: [Available Mesh BoomBox | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#QCU8DJ#260). You should debug your code to ensure there are no mistakes.

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [October 7, 2022, 12:30pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/3 "2022-10-07T12:30:20Z")

</div>

I think the issue is that decals aren’t supported for meshes with skeletons?

Also here’s the other thread on this topic for reference:

> [@Trying to add decal on avatar t-shirt](https://forum.babylonjs.com/t/trying-to-add-decal-on-avatar-t-shirt/34468):
>
> Hi all, We are trying to add sticker on t-shirt front side using decal approach. Using scene.pick method am trying to get coordinates on t-shirt front side but somehow am missing getting blank. can somebody suggest where am making mistake ? Thanks vij

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [October 7, 2022, 12:39pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/4 "2022-10-07T12:39:23Z")

</div>

Hey, I think it is something related to decal size maybe.  
gltf - [https://playground.babylonjs.com/#1YTZAC#180](https://playground.babylonjs.com/#1YTZAC#180)  
glb - [https://playground.babylonjs.com/#8LFTCH#1453](https://playground.babylonjs.com/#8LFTCH#1453)  
even animated glb - [https://playground.babylonjs.com/#ISZ7Y2#66](https://playground.babylonjs.com/#ISZ7Y2#66)

ps: I checked, … and maybe it is not related to decal size 😅

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#EEUVTY%23141)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

I got some warnings when I want to create the decal  
‘Setting vertex data kind ‘position’ with an empty array’  
basicaly means we want to create the decal without ‘positions’. Close but still I don’t have a final answer why it is not working on your model. 😒

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 7, 2022, 1:05pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/5 "2022-10-07T13:05:23Z")

</div>

Hmmm, I think the decals can also go a bit under the mesh in case it’s deformed by skeletons. Like this case: [Available Mesh BoomBox | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#QCU8DJ#261)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 7, 2022, 1:08pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/6 "2022-10-07T13:08:40Z")

</div>

I’ll take a deeper look into this example, thanks!

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [October 7, 2022, 1:37pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/7 "2022-10-07T13:37:18Z")

</div>

It looks like if these two lines from CreateDecal were changed to be like below then the decal’s initial position and rotation could be computed accurately even if the mesh was deformed by skeleton or morphing. It might not make sense to do thou because the decal wont stay stuck to the mesh if it’s animated anyway, but if the animation is paused or stopped then it seems to work well (from my testing with the model in the OP)…

```auto
const positions = sourceMesh.getPositionData(true, true);
const normals = sourceMesh.getNormalsData(true, true);

```

> <https://github.com/BabylonJS/Babylon.js/blob/b0d22250dcdea276278f56a9719a58ff75e08aa2/packages/dev/core/src/Meshes/Builders/decalBuilder.ts#L32>

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 7, 2022, 1:47pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/8 "2022-10-07T13:47:27Z")

</div>

Oh, checked here and that seems to do the trick! I think we could control this through an optional flag, something like `applySkeletonsAndMorphs`, as these functions are slower than `getVerticesData`. Want to do a PR? 😃

---

<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:** [October 7, 2022, 1:53pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/9 "2022-10-07T13:53:31Z")

</div>

I’m not sure it’s the solution, as @Blake pointed out it won’t work when the mesh is animated (the decal won’t follow the animation).

It must be something specific to the model as @MarianG showed in [https://playground.babylonjs.com/#ISZ7Y2#66](https://playground.babylonjs.com/#ISZ7Y2#66) that decals can work even with animated models loaded from a glb file…

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [October 7, 2022, 2:21pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/10 "2022-10-07T14:21:35Z")

</div>

EG if I pause the animation in that shark PG and rotate to check diff parts thou, I can see that the decals are wrong for many parts of the mesh because the skeleton isn’t applied…

Also the original PG had some other issues, I got it working by removing the predicates from the picking and passing the pickedMesh to CreateDecal. Here’s the [PG](https://www.babylonjs-playground.com/#EEUVTY#148) I used for testing with the skeleton applied (it stops the animation when a mesh is picked to test that the decal is created properly).

IDK what the solution is for keeping the decal in sync with the animated mesh thou. ☹ The proposed changes would only help with paused/stopped skeleton animations and non-animated morphs I guess…

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [October 7, 2022, 3:55pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/11 "2022-10-07T15:55:12Z")

</div>

Here’s a simpler PG to reproduce the warning “Setting vertex data kind ‘position’ with an empty array” with just a simple box mesh. If you comment out line 37 that disposes the old decal the error goes away. IDK what the issue with disposing them is. 🤔

> **[Babylon.js Playground](https://playground.babylonjs.com/#ISZ7Y2%2367)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

EDIT: moved this part to a new [bug report](https://forum.babylonjs.com/t/error-when-disposing-a-decal/34589). 🙂

---

<div class="post-metadata">

**Author:** ![vijay\_krishna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vijay_krishna/32/18667_2.png) [@vijay\_krishna](https://forum.babylonjs.com/u/vijay_krishna)\
**Post date:** [October 7, 2022, 5:22pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/12 "2022-10-07T17:22:50Z")

</div>

Hi,  
@Blake u r right if animation is stopped its working well…  
i think decals does not support Rigged avatars. i tried with t-pose avatar its working  
Need to find some workaround to apply for Rigged avatars.

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#EEUVTY%23149)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [October 7, 2022, 5:56pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/13 "2022-10-07T17:56:05Z")

</div>

Hmm there’s an older thread discussing a work-around using a dynamic texture. They also ruled out using attachToBone() which I hoped might work for this. Maybe @ozRocker will have some more insights about it? 🙏 🙂

> [@Decals on animated mesh](https://forum.babylonjs.com/t/decals-on-animated-mesh/1804):
>
> I’m trying to get the decal moving with the mesh. I searched around and saw this post from the old forum: but its still a mystery to me. I can successful clone mesh, skeleton and the animation but then what do I do with the decal? Do I merge it with the clone?

---

<div class="post-metadata">

**Author:** ![ozRocker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ozrocker/32/186_2.png) [@ozRocker](https://forum.babylonjs.com/u/ozRocker)\
**Post date:** [October 7, 2022, 10:27pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/14 "2022-10-07T22:27:57Z")

</div>

I never had a proper Babylon.js solution for this. I’m still using a Python call to a compiled Blender module to bake the decal on the same UV map

---

<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:** [October 8, 2022, 5:44pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/15 "2022-10-08T17:44:18Z")

</div>

@Blake You’re right, I think the new (decal) mesh would need to have the matrix indices/weights filled correctly as well as using the same skeleton than the source mesh for decals to work correctly for rigged characters… I will try to have a deeper look about this issue.

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [October 8, 2022, 6:06pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/16 "2022-10-08T18:06:11Z")

</div>

Oooh awesome, it would be amazing to support! 🍻 🙂

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 10, 2022, 11:07am UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/17 "2022-10-10T11:07:37Z")

</div>

@Evgeni_Popov want me to create a Github issue to track progress? 🙂

---

<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:** [October 10, 2022, 12:44pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/18 "2022-10-10T12:44:12Z")

</div>

Yes, thanks!

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 10, 2022, 1:30pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/19 "2022-10-10T13:30:41Z")

</div>

[Support skinned/skeleton meshes on decals · Issue #13084 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/issues/13084) 🙂

---

<div class="post-metadata">

**Author:** ![vijay\_krishna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vijay_krishna/32/18667_2.png) [@vijay\_krishna](https://forum.babylonjs.com/u/vijay_krishna)\
**Post date:** [October 11, 2022, 1:18pm UTC](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571/20 "2022-10-11T13:18:33Z")

</div>

Thanks @Evgeni_Popov for the support

[Next page](https://forum.babylonjs.com/t/decals-are-not-supported-for-glb-files/34571.md?page=2)
