Same mesh used for LOD on multiple other meshes

I recently started optimizing my app and in an effort to keep framerate higher, I was going to use 2 levels of detail for planes that have dynamic text textures. After playing around with webgpu and multiviews (ran into issue with both) I decided to give using LOD a try.

First off, if I set LOD to null at a reasonable distance (like around when text becomes unreadable) it works great! Text meshes disappear and framerate jumps back up!

So then I thought to myself “self, maybe we have an intermediate LOD that is just a basic material so that users can know there is text there…it’s just unreadable”… well, then things got wierd. Works absolutely fine when using a new mesh for every mesh, but if I try to reuse same mesh or instances or thininstances it doesn’t work. I’ve seen a lot of feedback indicating this is kinda…just the way it works. But I have a more fundamental question, namely:

Does this not work because of some technical reason that makes it impossible? or is it more like “we haven’t gotten around to it yet?”

example:

    distantMesh = MeshBuilder.CreatePlane("distantPlane", {width: planeWidth, height: planeHeight}, scene);
    const material = new StandardMaterial("distantPlaneMaterial", scene);
    material.emissiveColor = Color3.White()
    distantPlane.material = material;

//this works fine with a "regular mesh"   
   detailMesh.addLODLevel(distantMesh, 5);

//this doesn't work...I'll need to double check if it works for maybe one of them, but in general it doesn't work
   detailMesh1.addLODLevel(distantMesh, 5);
   detailMesh2.addLODLevel(distantMesh, 5);

//this doesn't work, no errors, just doesn't work
   detailMesh.addLODLevel(new InstanceMesh('simpler', distantMesh);


Just curious.
   

Yes, you can’t reuse the same mesh for different LOD levels of different meshes, because a given mesh can only be rendered a single time in a render pass. I don’t think it would be easy to fix, as it’s just how it works internally…

How do instances do this though? I was expecting that at least would work, but doesn’t seem to…

You can set LODs for a (regular) mesh, then create instances from this mesh. The instances will use the right LOD depending on their distance to the camera.

1 Like

I missed this reponse initially…dang that’s kinda more straightforward/easier than I expected.

1 Like