same mesh having different texture

kubatp

02-11-2009 12:52:45

Hi,
I have a quick question. I have this flag stand with flag. It's one mesh. I would like to use this mesh with different flag texture. I.e. I would like to use this mesh and for every player have a different flag texture. What is the most efficient and easiest way to do this?
Thank you Pavel

smiley80

02-11-2009 15:28:54

You could assign individual materials to the stand and the actual flag in your 3d editor. The exporter then divides the mesh into 2 submeshes. Which means, you can change the material of the flag without changing the one of the stand.
E.g.:
myFlagEntity.GetSubEntity(<0 or 1>).MaterialName = "GermanFlag";

kubatp

02-11-2009 15:41:29

Hi Smiley,
thank you again and again for you replies.

I know about this option and it was the first one which came to my mind. The question here is the performance. There are two questions I have regards to this solution:
- I need to have x new materials, where x means the number of players. In higher number of players (100), it could be a performance bottleneck, don't you think?
- Will the submesh be reused across all the objects? Or it will create new ones? From what I see here, it changes the material name of the entity, so the mesh itself should stay as it is and doesn't have to be cloned, correct?

I was wondering about another solution:
- Have atlas texture with all the flags used. For each player clone the submesh and set UV coordinates according to the flag.

What do you think is a better solution (from performance point of view)?
Thank you Pavel

smiley80

02-11-2009 17:13:20


- I need to have x new materials, where x means the number of players. In higher number of players (100), it could be a performance bottleneck, don't you think?

When the textures are very very large you might run into memory issues.


- Will the submesh be reused across all the objects? Or it will create new ones? From what I see here, it changes the material name of the entity, so the mesh itself should stay as it is and doesn't have to be cloned, correct?

You only change the material of the particular entity not of all entities with the same mesh.


- Have atlas texture with all the flags used. For each player clone the submesh and set UV coordinates according to the flag.

I don't think that reduces the number of batches, so you won't benefit from it.

Performance-wise, it's better to have as few submeshes as possible, i.e. only one material.
But I'd check first whether there is a significant performance impact.

kubatp

03-11-2009 23:37:55

The solution works perfectly. Thank you!