Placing decals on freshly instantiated meshes

Hello again!

After a while I came back to my small project with an idea to place an image on top of every block.
I tried to use decals for it but I don’t really know what is wrong. Every example I checked was using casting to place a decal on top of the mesh and I would like to do it instantly when I initialize the block.

Here’s slightly modified example:

I don’t know why I am getting only a black rectangle or a square instead of an image that I got from this example:

Also when I am trying to do the same thing on my main project where blocks are InstanceMesh’es from .gltf file, I kinda see decals as “inverted”? I can somehow see them when I look at the blocks from the bottom - reversed situation of when you look at the ground from the bottom and it is invisible. Pretty hard to explain :sweat_smile:


The position used to project the decal should not be right on the mesh you project onto, it should be a little further, else the algorithm won’t work well:

Regarding your other problem, try to set scene.useRightHandedSystem = true just after creating the scene and see if this fixes it.

1 Like


First problem was indeed fixed.
I can see in my project that it is also working if am using a simple MeshBuilder.CreateBox() to create my blocks. Sadly, problem when using imported mesh still persists even with setting useRightHandedSystem as you suggested. Here’s a screenshot of what I am seeing. Decal settings are left untouched (the ones working with simple meshes from builder)

Can you reproduce the problem in the playground? I think it will be difficult to help you otherwise.

Hey @Evgeni_Popov ! Sorry for the delay, I had some problems with importing my custom mesh to the Playground. Luckily, I managed to reproduce exactly my problem. You can see it here:

I increased decal’s size so it would be “visible”.

Thank you for your interest in my problem!

Because you load the base mesh from a glTF, you must update the sideOrientation property of the decal material to account for the different handedness between glTF and Babylon (see line 102):


Hey Evgeni! Damn, such simple fix, thanks for that!
I am marking your post as a solution.

Have a great day!