GUI Text with Texture


I am looking for a way to have a customizable Text on a Mesh with a material like in this image:

I know we can use GUI to draw text on any Mesh but I did’nt find a way to have PBRMaterial applied on it. Is it possible?
Maybe using something like a dynamicTexture?

Thanks a lot for your ideas and help :wink:

Gui is using canvas 2d to draw the text so nope it can not be rendered with a pbr material.

Nevertheless why not using it to generate your pbr textures or coupled to Node Material to achieve the desired effect ?

How can I do that?

I guess the idea is to use the GUI as an opacity texture and apply it to a mesh that has a PBRMaterial? Would it work?
I am not an expert with node material so I would prefer a code solution :wink:

yup it should work.

1 Like

Tempted to make a demo for this myself. Will be back… :wink:

1 Like

I made some first test here:
But for now I don’t really understand what is happening haha

With this is it the UV wrapping that is not correct. I’m still playing around with a sphere atm. This might be easier to start.

Well at least it works on a sphere and with the metallic:
I put the background in blue and the text in green to follow PBR rules.

Next: doing that on a model and with opacity :muscle:

1 Like

So I tried with the opacityTexture but I can’t make it work, now the background is black and the text white for opacity:

I tested to change alphaMode, transparencyMode or needAlphaBlending values but none have worked. Any ideas?

I manage to make it work using albedoTexture but not with opacityTexture:

But my material already has a defined albedoTexture so I don’t want to modify it.
What am I missing to make it work with opacityTexture?

Ok here we go:

Playing with the PBR parameters made it work:

    pbr.alphaMode = BABYLON.Engine.ALPHA_ADD
    pbr.useRadianceOverAlpha = false;
    pbr.useSpecularOverAlpha = false;
    pbr.opacityTexture.getAlphaFromRGB = true

If I do the exact same thing on a model, it stops working:

But I can’t see why?

The model UVs need to fit with the texture you are trying to apply

How can make my texture and model UVs match?

I need to place the texte wherever I want on the mesh. I should be able to do that playing with texture offset and scale right?

Not really, as what you are describing here is more a decals

Indeed @sebavan the solution is maybe to use decal:

Working with an opacityTexture:

Now I just have to figure out how to place and scale precisely the decal!

1 Like