Trying to add runtime engraving on specific 3d model mesh

I have GLTF 3d Ring model and I have one requirement to add inside engraving on specific mesh and second requirement to do it on runtime, it’s mean I will have some input that every time it change it reflect the input value on specific position ring

I add small research and I think of two options

  1. Use 3d Text and somehow link it to specific mesh, but the 3d text wont be really connected to the
    parent mesh.
  2. Create dynamic texture on runtime and use bumpMapTexture or something like that.

thanks for the help and god bless you all :slight_smile:

It all depends on the ultimate purpose of the visualization :slight_smile: The bump map approach will be faster, but if examined up close, the result will likely be less convincing. And since it doesn’t modify the geometry, it couldn’t be used for manufacturing, for example. Using 3D text + CSG takes a lot longer, but the result is more “realistic” and the model could be exported for something like 3D printing.

1 Like

hey @carolhmj thank for the quick answer :):slight_smile:

I succeded to create dynamic texture with text on it and connect it to the main PBR Material, it’s not look so good but it a start

  1. do you think it can be better?
  2. I assign the dynamic texture to albedoTexture and it makes all the material black, any idea?

you check it here

Could you share smthg similar in th playground so we can help troubleshoot ?

this is my react repo

I will try to create some playground to make it more comfortable

@sebavan this playground can help?

i wont address the material aspect going black (but you obviously can just asign your texture to albedo , replacing your current one , babylon supports decals i believe ) but other than that , It looks like your UV’s are stretched , this is something you have to fix within the 3d model itself , not a fault of the babylon engine.\

You might have to create diffferent seams and do very specific per island unwrapping to get rid of the stretch.

Depending on the surface complexity or even just for ease of use , this is also sometimes handled by a section of geometry just above the first , using a transparent material in the style of a decal.

@shaderbytes I know the model not good and I’m working to fix it,

about material going black issue, I assign my texture to albedo, maybe I doing something wrong?

Since you use PBR material, you need to have some environment texture.
If your texture is black, try to add this line:


Here is the example of Dynamic texture on PBR material -

1 Like

also for an engraving effect , this is a bit more complex that just doing a diffuse update. To get a proper look to it, you need to create a grey scale image that you can convert to a normal map if you want it to actually look engraved. Aso consider using more channels like occlusion maps but it needs to be subtle.

I add enviorment once I creating the scene

    const onReadyScene = (scene: SceneType) => {
        const envTexture = new CubeTexture("environments/1.env", scene);

        scene.environmentTexture = envTexture;
        scene.environmentIntensity = .6

ye it can be much more tuff to do hahh

I try now to check implementation and use DecalMap

const shina = metalMaterial.getBindedMeshes().find(mesh => === "node4");
const decalMap = new MeshUVSpaceRenderer(shina!, scene!);

decalMap.renderTexture(text, Vector3.One(), Vector3.One(), Vector3.One());
metalMaterial.decalMap!.isEnabled = true
shina!.decalMap = decalMap

I wondering why it’s not working … any idea?

Can you try to narrow the issue in a babylon playground ? it would be much easier for the rest of the community to help :slight_smile:

It is really hard to jump on each questions project and we usually only do it when it is a project level issue. For code only the babylon playground should be fine.

did you look here :

maybe this :

Note that you must enable support for decal maps (material.decalMap.isEnabled = true ) before rendering with the material! This is because a material plugin must be added to a material before the first rendering, and decal map is implemented by the material plugin mechanism. However, you can disable/enable the decal map rendering at any time by updating decalMap.isEnabled . You can even start in a disabled state and enable it later, but the important thing is to set a value to material.decalMap.isEnabled (or even just access material.decalMap ) before the first rendering. If you don’t do this, material.decalMap will always return null .

1 Like