devour Posted June 18, 2018 Share Posted June 18, 2018 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted June 18, 2018 Share Posted June 18, 2018 Hi, in this case you will need to clone the material and set a different texture for each of them. devour 1 Quote Link to comment Share on other sites More sharing options...
devour Posted June 18, 2018 Author Share Posted June 18, 2018 1 hour ago, RaananW said: Hi, 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 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 18, 2018 Share Posted June 18, 2018 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) unobruno 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 18, 2018 Share Posted June 18, 2018 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. https://www.babylonjs-playground.com/#A9K31I#3 Wingnut, jerome and unobruno 3 Quote Link to comment Share on other sites More sharing options...
devour Posted June 18, 2018 Author Share Posted June 18, 2018 am i able to drag an drop particles of a sps ? Quote Link to comment Share on other sites More sharing options...
jerome Posted June 18, 2018 Share Posted June 18, 2018 http://doc.babylonjs.com/how_to/solid_particle_system#pickable-particles unobruno 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 18, 2018 Share Posted June 18, 2018 (Jerome is avoiding talking about the drag/drop part. He speaks only of picking.) http://playground.babylonjs.com/#UZ23UH#0 Make same functionality... with SPS boxes. 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. unobruno 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2018 Share Posted June 18, 2018 Quote "Transformers... more than meets the eye." I always struggle to understand which eye this song is referring to unobruno and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
RaananW Posted June 19, 2018 Share Posted June 19, 2018 The right eye unobruno 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2018 Share Posted June 19, 2018 drag/drop is just a behavior applied on the pickability ... like it's implemented in the lagacy drag/drop example unobruno 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2018 Share Posted June 19, 2018 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 http://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors http://doc.babylonjs.com/how_to/set_shapes 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. Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 20, 2018 Share Posted June 20, 2018 @devour 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. DB Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.