If I build a town with the same buildings (same mesh, different materials, different transformations) would the scene be more optimised if I combined them all as one mesh or if I just loaded the one building and cloned it many times?
It depends on how you want to optimize it.
Less meshes means less draw calls, but bigger, combined meshes means bigger file sizes, loading- and parsing times. What I do is, I load a single mesh and clone it X amounts of time based on where I need the mesh. Then I merge those meshes based on material, as to reduce draw calls down to one. I’m using a texture atlas, so more or less all my static meshes can be merged into one single mesh for performance reasons.
This way, you can even change the UVs of a mesh when you clone it, to change the texture coordinates
I created a simple map editor, which saves to JSON. So instead of a 400MB .babylon file, it becomes a 3-4MB .json file. This gives me reduced the loading times as well as reduced draw calls.
From what I have observed so far - using instances mesh.createInstance() wherever possible is far superior to clones. If you have some meshes that share the same material, using instances is the way to go.
IMO using clones doesnt have any impact fps-wise - it might be slightly faster to initialize in the first place, but later clones are just fresh standalone meshes am I right ?
Merging meshes together seems to also have big impact on FPS - simmilar as using instances (merge instances together seeem to have no effect whatsoever).
I dont have any background knowledge to support that observations, just sharing what I have learnt so far regarding optimization.
An alternative would to use SPS one draw call for many models. Since (I assume) the houses once created will not be changed then you can use immutable SPS
Instancing is likely to use the least resources given your description. See Babylon.js Documentation.
I’m using the Unity exporter to export 3D cities into .babylon files. Not sure if the exporter supports instancing and cloning though
I spent a whole day re-doing a city in Blender (bought from TurboSquid) to use linked objects for instancing. That was kinda painful, but it knocked down the .babylon filesize from 7MB to 3.5MB
I have some other cities made in Unity but the Unity Exporter doesn’t support instancing (unusual 'cos the use of prefabs is common). I’ll have to edit the source code of the exporter to fix that.
One of these cities has 70 textures (13MB in total). Would it be more efficient if a texture atlas was used instead? I have no idea how to do that from within Blender or Unity