Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
franky-adl opened this issue Jul 7, 2024 · 1 comment · Fixed by #2020
Closed
Labels
bug Something isn't working

Comments

@franky-adl
Copy link

Dependencies on codesandbox demo:

  • "@react-three/drei": "9.108.1",
  • "@react-three/fiber": "8.16.8",
  • "@react-three/postprocessing": "2.15.12",
  • "@types/three": "0.158.3",
  • "leva": "0.9.33",
  • "react": "18.2.0",
  • "react-dom": "18.2.0",
  • "react-scripts": "5.0.1",
  • "three": "0.166.1"

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>
@franky-adl franky-adl added the bug Something isn't working label Jul 7, 2024
@CodyJasonBennett
Copy link
Member

Fix released in 9.108.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants