pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.23k stars 675 forks source link

Fail to set instanceColor buffer attribute for instances with MeshRefractionMaterial #2019

Closed franky-adl closed 2 months ago

franky-adl commented 2 months ago

Dependencies on codesandbox demo:

Problem description:

The 'instanceColor' buffer attribute has no effect on instances using MeshRefractionMaterial, no matter what color you've set in the InstancedBufferAttribute, the diamond stones in the sandbox just turn out 'white'. However, testing with other materials (e.g. meshBasicMaterial or meshPhysicalMaterial) instead of MeshRefractionMaterial proves fine, various colors can be set onto the instances like in the following image.

image

Relevant code:

Demo running on codesandbox: https://codesandbox.io/p/sandbox/diamond-ring-forked-fqwllc

The code for the instancedMesh component:

<instancedMesh castShadow args={[nodes.mesh_4.geometry, null, count]} instanceMatrix={nodes.mesh_4.instanceMatrix}>
        <instancedBufferAttribute attach="instanceColor" count={colorArray.length / 3} array={colorArray} itemSize={3} />
        {/* try toggle between refraction and physical material */}
        <MeshRefractionMaterial color={diamonds} side={THREE.DoubleSide} envMap={env} aberrationStrength={0.02} toneMapped={false} />
        {/* <meshPhysicalMaterial color={diamonds} side={THREE.DoubleSide} envMap={env} toneMapped={false} /> */}
</instancedMesh>
CodyJasonBennett commented 2 months ago

Fix released in 9.108.3.