# Drawing multiple meshes with the same material, attributes / uniforms per mesh

**URL:** <https://forum.babylonjs.com/t/drawing-multiple-meshes-with-the-same-material-attributes-uniforms-per-mesh/51984>\
**Category:** Questions\
**Created:** [July 10, 2024, 3:51pm UTC](https://forum.babylonjs.com/t/drawing-multiple-meshes-with-the-same-material-attributes-uniforms-per-mesh/51984 "2024-07-10T15:51:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [July 10, 2024, 4:48pm UTC](https://forum.babylonjs.com/t/drawing-multiple-meshes-with-the-same-material-attributes-uniforms-per-mesh/51984/3 "2024-07-10T16:48:10Z")

</div>

> [@axeljaeger](#):
>
> Is there a way to attach some data to a mesh(hover, selected, errorState to draw them in red) that will be then available in the material so I can draw multiple meshes with the same material but slightly different rendering?

As Roland said, it’s common to use VertexColors, as long as it fits your needs.

If you need to save something which is not compatible with a per-vertex color, still you can have an input in a Shader, and set it per mesh (with the same material for different meshes). Have a look at [this topic](https://forum.babylonjs.com/t/nodematerial-how-to-efficiently-set-per-mesh-value/51590) where I was giving as an example this [Playground](https://playground.babylonjs.com/#SO4N91#14) (`instanceColor` is a color to be used in the shader, `customValue` is a `float` for whatever usage)

> [@axeljaeger](#):
>
> What do you think about using one mesh for all polygons and just use a different faceId/subMeshId for each polygon

Depends on the scene I would say. Merging all geometry in one mesh can be efficient when the mesh is fully present in the Viewport (since, whatever, all would have been rendered anyway). But if some submeshes are not in the Viewport, I means you are somethow loosing performance since if it where a single object, it could have been 100% skipped by the GPU.

---

_[View the full topic](https://forum.babylonjs.com/t/drawing-multiple-meshes-with-the-same-material-attributes-uniforms-per-mesh/51984)._
