Hello
I am implementing the LOD for my InstancedMesh2 library and would like to share with you the first result.
In this example there are a million instances (but it’s possible to edit the example), which change color (and geometry) depending on the distance. This is done using a BVH.
There are several things to improve including support for shadows, render the nearest layer first and make a unique drawcall for objects that share the same material.
Edit: https://instanced-mesh2-lod-demo.vercel.app/
Live example: three.ez/InstancedMesh2 - InstancedMeshLOD - StackBlitz
7 Likes
This sounds amazing but unable to run like official webgpu examples from three on huawei p30… …
1 Like
thanks
this is the current code:
const instancedMeshLOD = new InstancedMeshLOD(main.renderer, count);
instancedMeshLOD.addLevel(new SphereGeometry(5, 30, 15), new MeshLambertMaterial({ color: 'green' }));
instancedMeshLOD.addLevel(new SphereGeometry(5, 20, 10), new MeshLambertMaterial({ color: 'yellow' }), 100);
instancedMeshLOD.addLevel(new SphereGeometry(5, 10, 5), new MeshLambertMaterial({ color: 'orange' }), 500);
instancedMeshLOD.addLevel(new SphereGeometry(5, 5, 3), new MeshLambertMaterial({ color: 'red' }), 1000);
instancedMeshLOD.updateInstances((object, index) => {
object.position.x = random.range(-spawnRange, spawnRange);
object.position.z = random.range(-spawnRange, spawnRange);
});
instancedMeshLOD.computeBVH();
2 Likes