Jump to content

How to share Textures from ObjectText nodes


photo

Recommended Posts

Hi

We have a rather big amount of ObjectText Node (amount, transformation, and text defined by the end user) and many of them (maybe a hundred) are basically exactly the same text (and same font, same resolution, same size, etc). Also, they are part of the 3D World (the size is constant in the world), potentially scattered everywhere. An example would be speed limits on a highway: it's a lot of the same value over and over again...

To spare memory, I would like to have the texture with the same rendered text only once for all instances that require it.

I could not find a way to clone the ObjectText nodes, at least not one that would guarantee I have the texture only once.

I could not find a way to make a cluster out of ObjectText nodes (maybe I missed something...).

I tried to apply the material of a ObjectText to a mesh (with the intent to instanciate this mesh in a cluster later), but that didn't work either. I guess because the material is not ready yet... (?)

ObjectTextPtr first_text = ObjectText::create();
first_text->setText("Hello World");
first_text->setFontName(...)
...
MaterialPtr first_text_material = first_text->getMaterial(0);

ObjectDynamicMeshPtr copy_of_text = ObjectDynamicMesh::create();
MeshPtr copy_of_text_mesh = Mesh::create();
// create quad with text height and width (out of first_text->getBoundBox())...
copy_of_text->setMesh(copy_of_text_mesh);
copy_of_text->setMaterial(first_text_material,0);

(code from memory, actual code may be slightly different)

Again, the text is freely defined by the end user, therefore we cannot generate DDS textures with the text beforehand.

Currently I see two possibilities if I want to avoid goups of about a hundred of the same texture:

1. Baking the text into a texture ourselves, and reusing the material where needed

2. Generating the ObjectText nodes on the fly, depending on the camera position. This is *not* the direction I want to go...

 

Does anyone have experience or a suggestion here?

How can I reduce the amout of textures with the exact same text?

 

Edited by gr7.76
Link to comment

Hello!

There is no way to make work ObjectText as you want. The proper solution for this use-case would be to generate a texture and "bake" the text into it. Later you can use this texture as a decal or assign directly to the mesh_base material.

Here is an example of baking text into a texture using a 3rd party library: 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...