Jump to content

How to draw text on meshes with the same material


Recommended Posts

Hey guys, i need ur help.

Is it possible to use a different dynamic texture on all meshes with the same material? I want to draw different text on each mesh. the meshes should be only different in their position, rotation, scaling and the text on it.

Best regards and thx

Link to comment
Share on other sites

1 hour ago, RaananW said:


in this case you will need to clone the material and set a different texture for each of them. 

Is there a better way ? I create 1 to 300 boxes. If i clone the material and set a different texture for each of them i got performance problems. the performance even goes as far that the game become unplayable

Link to comment
Share on other sites

Hi guys.  They are boxes, eh?

Can text be on only one side?  Would that be ok?

If so, there might be a sprite or Solid Particle System solution.  Create a sprite/sps plane on one side of each box, and then create a single "sprite atlas" texture that contains ALL the text used for ALL the boxes.

Then set UVS on each sps plane or sprite... so it has the wanted text from the correct texture atlas "cell".  Essentially, you are adding a "sign maker" to your box-maker factory.  :)

https://www.babylonjs-playground.com/#WCDZS#82  (not a perfect demo, but we can see how it might work)

I dunno if performance will improve, or actually get worse.  But... using one big texture can't be all bad.  (but can be sort-of bad)  :)

Link to comment
Share on other sites

1 hour ago, Wingnut said:

there might be a sprite or Solid Particle System solution

Here's an SPS version. By no means perfect and still a lot of work to do but here are some boxes that have a (albeit stretched) shared texture and different words on each box.


Link to comment
Share on other sites

(Jerome is avoiding talking about the drag/drop part.  He speaks only of picking.)  :)


Make same functionality... with SPS boxes.   :o

I wanna see it.  ;)  (My dog got scared and ran under the fridge again.)

"Transformers... more than meets the eye."  (tv commercial jingle from long-ago).

Actually, SPS particles have .position, so, should be do-able, in theory.

Link to comment
Share on other sites

about the initial question (one material and different texts), if you use some BJS provided mesh implementing the faceUV parameter in its constructor (like planes, boxes, etc), you could :

- create one big dynamic texture and write your different texts on it at separate different positions

- set this texture to a single material

- set the faceUV values of each mesh to match the wanted different texts

- assign the same material to every mesh




I just can't retrieve an old PG example I did about how apply a different image from the same texture/material to 2 separate meshes.

Link to comment
Share on other sites



Load your meshes or create them in a loop and assign the same material with a different var name++ for the dynamic texture in the material associated with the loop. And define each dynamic texture by the var++ name prior to the loop. This should be very simplified code.


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.

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.


  • Recently Browsing   0 members

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