No need to ping me, I read all posts
Reducing the materials save a lot using caching, it does not change the draw calls as draw calls depend only on the number of meshes.
merging is great:) What is your question then? Instances must be used every time an object is duplicated and need to be animated independently (like bullets)
I’ve been playing with it a bit more and was eventually quite happy, the video below shows performance with 8 same rooms - it’s pretty good, a few hiccups here and there.
Now the video below shows performance with 30 rooms - unfortunately totally unplayable, but I believe there is definitely something I am doing wrong because:
Draw calls is THE SAME as with 8 rooms, around 300.
There are max 70 materials on at the same time
There is around 1000 meshes, but only 100 active
The one that bugs me most, as you can see near the end, I switch to free camera and move out of the camera’s maxZ, so that the screen is eventually black, rendering nothing - still 30 fps.
I had the understanding that maxZ prevents rendering of stuff outside of the camera’s view?
Yes, it has certainly helped me a lot when trying to optimize performance. Another question, do you merge all the furniture in one mesh? Or do you merge them per room?
What I have implemented in one of my games where I had a lot npcs in the same 500*500 map was some custom culling. What I did was I removed the mesh from the scene when out of frustrum and added them back when in frustrum. Helped me get a consistent 30 fps with over 2000 npcs in the map. Maybe this can help, worth trying anyway
Removing from scene? I don’t think it does that. No, I meant scene.removeMesh(mesh);. Adding back with scene.meshes.push(mesh). Checked frustrum with camera.isInFrustum(mesh)
Oh, something which probably affects it. Since mine was a multiplayer game, I had positions coming from the server for the npcs. I had to manually compute the world matrix with mesh.computeWorldMatrix() when the mesh was not in the scene. Not sure how it affects you but just so you know
I will not remove the players, just the static meshes, so all should be fine It will probably affect bullets tho (you shoot at a wall, turn around, wall disappears, bullet moves through lol), but I wanna try it and and see if it helps the FPS.
I did not use it for static meshes. Instead I used LOD for static meshes. Use LOD - Babylon.js Documentation . Now that I think of it, I am not sure why I never did. Anyway, let me know if it helps.
Also, I saw you have animated robots. Not sure if you already do it, but, when out of view, stop the animations. Nobody sees it and it gets real expensive real quick in terms of fps.
Ok that helped a ton, standing still back to 60fps, but when moving around, it drops a lot. So definitely not rendering stuff when out of view is the key. Good call!