Some question about using LOD to simplify mesh

What does the distance parameter of ISimplificationSettings stand for?
Is it the distance between the mesh and the camera, or the vertical depth of the mesh from the screen or something else?

I want to implement a feature where I can help the user get the distance parameter. If the user changes the camera field of view, the distance parameter can be automatically updated to help the user design the ISimplificationSettings.

Can such a feature be implemented?

Looking forward to your reply, thank you

For LOD you may define the distance to viewer (by default), or screen coverage. It is performed at mesh level

mesh.useLODScreenCoverage = true;

In this case values must be between 0 and 1

mesh.addLODLevel(0.1, knot01);

In this case bigger value means a bigger size on the screen, and thus a more detailed LOD. This is the opposite order than with distance, where a big distance meant a smaller size, and therefore a less detailed LOD.
More info - Babylon.js docs

Example - https://playground.babylonjs.com/#2JBSNA#285

Note that if you do it more than once you need to dispose all simplified meshes, otherwise they will add to the previous ones, and remove LOD settings.

            newMeshes[0].removeLODLevel(null)
            while(scene.getMeshByName("testDecimated")){
                scene.getMeshByName("testDecimated").dispose()
            }

Example - https://playground.babylonjs.com/#2JBSNA#287

Names of decimated meshes = yourMesh.name + “Decimated”.

3 Likes

Thank you for your reply!

If I have more than one camera in the scene, is that every camera need ISimplificationSettings alone setting?

No, the LOD levels are camera independent. I believe in this case you need to implement some own code to calculate the average FOV or some another value used for simplification.
If you need separate LOD treatment for different cameras you need to clone all meshes, assign LayerMask to them and to the second camera and then perform a separate simplification. But this may be quite perf heavy and not optimal from the common sense of view.

if I set ‘mesh.useLODScreenCoverage = true;’

I manually calculate the screen coverage of the mesh and set some columns of mesh according to the screen coverage to achieve LOD switching based on screen coverage.

Is it possible to achieve LOD grid display under different cameras?

Could you explain how it should look like?

I’m sorry, I think I’ve got the wrong question. I would like to ask if babylon provides an automatic face reduction function?

As one may see, in the beginning the skull has 74998 faces.

.

With the simplification it has (with the hardest settings in the PG) 7498 faces

I believe one may call it ‘faces reduction’ because it is really face reduction, the number of faces reduces greatly.

1 Like

thank you!

1 Like