Jump to content

Draw text on transparent texture with emissive material


inxs
 Share

Recommended Posts

Thank you deltakosh! :)

1. Can I improve the rendering quality of the text?

2. Yes I tried it, but I dont want the text to be always on top, I want to have it integrated into the 3D space.

Link to comment
Share on other sites

Hello Deltakosh,

thanks for your answer! :)

1. Can you show me an example how to do this, currently my text is looking like this.

text3d.thumb.png.a3be5b2ea6f092d56fbb71b9bdff4136.png

2. Currently Im rendering on a 200x200 plane. This way it is not possible for me to align the text to the right, depending on how large the text is. Do you know a better solution for this?

Thanks

Jonny

Link to comment
Share on other sites

Thank you it works. The text is looking a lot better now!

Still I have the problem that - based on the zoomlevel - my text gets kind of a dark border when i zoom out.

text3.png.470573a9872386d5677aad482e03308c.png

It is not as "bright" orange as I would expect. If I zoom close it is looking wonderful.

This is my code for this section:

    const size = 1024;
    const textureSize = size * 4;
    const planeSize = size / 8.0;
    const textSize = size / 16.0;

    // Adding text
    const texture = new BABYLON.DynamicTexture('texture1', textureSize, this.scene, true, BABYLON.DynamicTexture.TRILINEAR_SAMPLINGMODE);

    // Rount Text to max. 2 trailing digits. the '+' removes trailing zeros
    texture.drawText(+value.toFixed(2) + ' mm', 0, (textureSize / 2) + (textSize) - (textSize * 3.5), '200 ' + textSize + 'em Roboto', '#ef890f', 'transparent', true);
    texture.hasAlpha = true;

    const textMaterial = new BABYLON.StandardMaterial('textureMaterial', this.scene);

    textMaterial.emissiveTexture = texture;
     textMaterial.opacityTexture = texture;
    textMaterial.disableLighting = true;

    textMaterial.freeze();

    const plane = BABYLON.Mesh.CreatePlane('', planeSize, this.scene);

    plane.material = textMaterial;
    plane.parent = this.dimmensions;
    plane.rotation = rotation;
    plane.bakeCurrentTransformIntoVertices();
    plane.position = position;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...