I know I am missing something simple… but I kept looking around and trying things and need some help. Here is my playground: https://playground.babylonjs.com/#5ZCGRM#946 . I’m just trying to get the background to be transparent so you can only see the text (I might also make the text emissive, hoping that’s also easy). Thank you.
I guess what I’m noticing is that (a.) you have a draw text method which initializes the text and then (b.) you have a fill text method changes the text.
The last positional thing I’m trying to do here (I may add a bloom later?) is change the font-size of the text dynamically as well. Do you have a suggestion for that?
Also, I want to learn what you know about re: this text drawing stuff; do you know if there is a good tutorial on the docs? and/or which documentation is most important to look at? (the basic tutorial did not cover these more advanced aspects we are looking at right now).
You are welcome. Not sure if you notice the different of initializing text and my code for updating the text.
Initializating text (your original code) is invoked on DynamicTexture. It is a BABYLON API. I believe underlying it updates the 2D canvas used as texture.
So basically, BABYLON DynamicTexture is using the content on the 2D canvas ‘textureContext’ and applies it on the mesh (the plane mesh variable ‘ground’ you created).
Now to update the content, you only need to update the 2D canvas as I showed by calling fillText method. This 2D canvas context is of type CanvasRenderingContext2D. It is standard HTML5 canvas directly supported by modern browser. It has nothing to do BABYLON. You can find all the available API functions you can use: CanvasRenderingContext2D - Web APIs | MDN
Changing text styles is described in this section: Text styles
You can also search for html5 canvas there should be plenty examples and tutorials online.
If you want a really good blending, you should generate the dynamic texture as a pre-multiplied alpha texture (by calling textureGround.update(true, true)) and override the OpenGL blending factors (you also need to set materialGround.useAlphaFromDiffuseTexture = true; as you are setting the dynamic texture to the diffuse slot):
Hi, this looks pretty good! But im using right hand system, and the text is mirrored. How can I flip it ? I try to use scale(1, -1), but it turns to black instead of transparent. Could you help me with it?