# Adding extra color attribute to instanced mesh

**URL:** <https://discourse.threejs.org/t/adding-extra-color-attribute-to-instanced-mesh/41886>\
**Category:** Questions\
**Created:** [August 25, 2022, 3:17pm UTC](https://discourse.threejs.org/t/adding-extra-color-attribute-to-instanced-mesh/41886 "2022-08-25T15:17:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfoller](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@tfoller](https://discourse.threejs.org/u/tfoller)\
**Post date:** [August 25, 2022, 3:17pm UTC](https://discourse.threejs.org/t/adding-extra-color-attribute-to-instanced-mesh/41886/1 "2022-08-25T15:17:29Z")

</div>

I use instanceColor in the custom fragment shader to render instanced mesh, at the same time I need to blend this color with another, also defined for each instance.

So I ended up assigning an attribute to instanced mesh geometry, like so:

```javascript
imesh.geometry.setAttribute('instanceRGID', 
new THREE.InstancedBufferAttribute(new Float32Array(rgID), 3));

```

It seem to work but my concern is that the attribute is instanced but the geometry isn’t, so I wanted to double check if it’s ok with the library?

On the other hand, I don’t see a different way to pass an instanced attribute to a vertex shader without modifying the library code.

> **[Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/tfoller/bwjfk2u4/)**
>
> Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.

---

<div class="post-metadata">

**Author:** ![Arthur](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/arthur/32/22954_2.png) [@Arthur](https://discourse.threejs.org/u/Arthur)\
**Post date:** [August 25, 2022, 5:48pm UTC](https://discourse.threejs.org/t/adding-extra-color-attribute-to-instanced-mesh/41886/2 "2022-08-25T17:48:46Z")

</div>

I’m not sure of how instanced attributes work, but I’ve had good results using [InstancedUniformMesh](https://protectwise.github.io/troika/three-instanced-uniforms-mesh/) for setting per instance uniforms ( that are treated as attributes under the hood ).
