Here I’m using a model in my scene, I want to change the model from the current model to “https://raw.githubusercontent.com/AK228212/Multi-Scene-Babylon/main/public/assets/Model_front.glb” this model when my camera comes closer to the current model. Can we switch these models in real-time while I’m in a game to improve my FPS?
The reason I want to achieve this is because of the FPS drop caused by using this model which has more triangles. I tried Merging all the meshes, this didn’t fix the issue completely but when I’m far away from the model I’m getting more FPS and while I’m getting closer and closer the FPS is dropping drastically,
Below is the link to the playground:
Yes you can. When creating/importing your mesh, you can give it LOD-levels (Level of Distance). This gives you the ability to define what mesh should be shown at what distance.
I believe the documentation should be enough to make it work. Just import both meshes in the begining and then do
currentMesh.addLODLevel(90, lowerQualityMesh). This means that if the camera is 90 units or more away from the mesh, it switches it to the lower quality mesh.
You also have the ability to switch the mesh based on what percentage of the screen the mesh takes up. For this, do
currentMesh.useLODScreenCoverage = true; and use LODLevel with a number between 0 and 1.
I got your idea of getting it done, but I’m not understanding how to implement it, Can you please help me to get the outcome? you can make the changes in the playground.
And i’ve given the 2nd model link for switching the model also.
I tried, but for some reason it doesn’t work. This is what I tried. I’m sure someone else will know what I did wrong / show you how to do it.
The meshes need to be merged for the LOD, like this example: LOD level 2 | Babylon.js Playground (babylonjs.com)