InstancedBufferGeometry UV mapping

So I’m dealing with InstancedMesh and trying to UV map per instance, but the only thing I get is instances with filled solid colors, each instance has different solid color so seems it works somehow! btw I don’t use a RawShaderMaterial, using threeJs standard material.
any help will be appreciated :slightly_smiling_face:

this’s my code :

const _material = new THREE.MeshBasicMaterial({ map : _texture });
const _InstancesRef = [
	{ uv:[0,0.5,  1,0.5,  0,0,  1,0] },
	{ uv:[0,1,  1,1,  0,0.5,  1,0.5] }
];
const _totalInstances = _InstancesRef.length;
const  _geometry = new THREE.InstancedBufferGeometry().copy( new THREE.PlaneBufferGeometry( 4, 2, 1 ) );
let uv = new Float32Array( _totalInstances * 8 );
for(let i=0,l=_totalInstances; i<l; i++){
	const UV = _InstancesRef[i].uv,
		idx = i*8;
	for(let j=0; j<8; j++){ uv[idx+j]=UV[j]; }
}
_geometry.setAttribute( 'uv', new THREE.InstancedBufferAttribute( uv, 2 ) );
const _InstancedMesh = new THREE.InstancedMesh( _geometry, _material, _totalInstances );

Pls check this out, I’ve tried all, without any result :
https://jsfiddle.net/ap9obj3z/

InstancedMesh does not automatically support instanced texture coordinates. Hence defining the uv attribute as an instanced attribute has no effect. You need a custom shader to make this work.

Thanks for the reply, is there any simple example to lead me in the right direction?

Update :
Finally Solved :smiley:

1 Like