You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even when using the same material and the same geometry, adding a new Mesh or InstancedMesh causes the node material to be rebuilt and the shader to be recompiled.
This can be clearly seen in the profiler screenshots: as soon as the second object with the same geometry and material is added, a new material build and shader compilation happens, even though the resources are identical.
Reproduction steps
After starting the example, spikes will be visible in the profiler.
Code
// WebGPURenderer({ forceWebGL: true })
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshStandardNodeMaterial();
setTimeout( () =>{
const mesh = new THREE.InstancedMesh( geometry, material, 100 );
for (let i = 0; i < 100; i++) {
mesh.setMatrixAt(i, new THREE.Matrix4().makeTranslation(i, 0, 0))
}
scene.add( mesh );
}, 3000 );
setTimeout( () =>{
const mesh = new THREE.InstancedMesh( geometry, material, 100 );
for (let i = 0; i < 100; i++) {
mesh.setMatrixAt(i, new THREE.Matrix4().makeTranslation(i, 0, 10))
}
scene.add( mesh );
}, 3100 );