# After merging bufferGeomtery is it possible have unique material for each geomtery?

**URL:** <https://discourse.threejs.org/t/after-merging-buffergeomtery-is-it-possible-have-unique-material-for-each-geomtery/28728>\
**Category:** Questions\
**Tags:** buffergeometry, merge, materials, geometry\
**Created:** [August 7, 2021, 5:08pm UTC](https://discourse.threejs.org/t/after-merging-buffergeomtery-is-it-possible-have-unique-material-for-each-geomtery/28728 "2021-08-07T17:08:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![orion\_prime](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/orion_prime/32/15785_2.png) [@orion\_prime](https://discourse.threejs.org/u/orion_prime)\
**Post date:** [August 11, 2021, 6:32pm UTC](https://discourse.threejs.org/t/after-merging-buffergeomtery-is-it-possible-have-unique-material-for-each-geomtery/28728/3 "2021-08-11T18:32:25Z")

</div>

Thanks!  
Successfully added vertex color to each of the geometry

[https://jsfiddle.net/orion\_prime/xqLskny5/6/](https://jsfiddle.net/orion_prime/xqLskny5/6/)

output test on updated gltfViewer !

 ![ver](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/2/e2cde31366aea9037b0e382543bd3acb1014403d.jpeg)

snippet

```javascript
const color = new THREE.Color();

	for (const mesh of allMeshes) {

		const count = mesh.geometry.attributes.position.count;
		const geometry = mesh.geometry.clone();
		geometry.setAttribute( 'color', new THREE.BufferAttribute( new Float32Array( count * 3 ), 3 ) );

		const colorAttr = geometry.attributes.color;
		color.copy(mesh.material.color)
		
		for ( let i = 0; i < count; i ++ ) {
			colorAttr.setXYZ( i, color.r, color.g, color.b );
		}
		
		geometry.applyMatrix4(mesh.matrix)
		geometries.push(geometry);
	}

	const mesh = new THREE.Mesh(THREE.BufferGeometryUtils.mergeBufferGeometries( geometries ), mergedMaterial)
	mesh.position.z= 2
	scene.add(mesh)

```

Now how do i do the UV method ? each geomtery’s uv points needs to be offset to a certain color of the atlas image

---

_[View the full topic](https://discourse.threejs.org/t/after-merging-buffergeomtery-is-it-possible-have-unique-material-for-each-geomtery/28728)._
