Batching Linked Objects in Scene?

Hi friends
I want to describe my question with an example.
I have a tree model and it’s name is bambooGrove.j3o. (Size is 874 KB)
In SDK I created a scene and named it Jungle.j3o. Then I linked 10 instance of the tree to this scene. then saved it. (Jungle.j30 size is 3.05 KB ).
Now I created another scene and named it JungleOptimized.j3o and linked 10 instance of the tree to this scene. Then right clicked on this scene in SceneExplorer and selected Batch Geometry. it created batched objects of tree. then I saved it. (now JungleOptimized.j3o size is 12.1 MB ).
As you noticed the size changed from 874 kb to 12.1 MB. it means for batching it recreated 10 separate mesh of the same tree.
I did this in a large scale (a big jungle ) and the size get more than 100 MB .
Before batching it was around 20-30 fps and after batching it also was like before. (I could not realize fps gain after batching ) .
So the question : In these kind of situation (as described above) is it good to batch linked objects ? and does it have any improvement in performance?
Or is there better way ?
And can we batch objects with different materials?

Thanks for any help.

Batching means creating one mesh, it depends on your scene setup if batching the whole scene is a good idea. You can’t batch objects with multiple materials because as said, it creates one mesh. See this:

Thanks @normen.
In video you had 3 houses with names house1.j3o , house2.j3o , house3.j3o and each one has separate mesh. I have no problem with this case.
But let me change the case. suppose you just have house1.j3o ( no house2 and house3). Then link house1.j3o to scene 3 times . In this case all of them use just one mesh in RAM. Ok? So as i understand there is no need to batch them . Am I right ?
But what about GPU. Are those 3 house1 being sent to GPU as one object to be rendered (like batched objects) or they are rendered separately ?
Edit: Is my question clear?

Sometimes it’s better to have all your trees as instances, sometimes - to batch them in chunks for streamed loading. And I think there could be situations where you’ll get better result by batching them all into one object as well, very specific situations though. Personally I prefer instancing over batching where instancing is supported but real instancing is working only in 3.1 and I’m not sure if SDK level editor supports it at all.

Separate objects are separate objects for the GPU, even if you put 1000s of blue boxes in the scene they will perform worse than one big mesh.

Okay. thanks for response.
these images show what i am doing.

in above image I linked tree model 5 times to scene. so all of them have just one mesh in RAM. so even though i link it 1000 times in scene the amount of memory is used is same as one tree. but in GPU all of them will be treated separately (like separate objects). So it will be memory efficient but GPU inefficient . Yes?

And if i batch them it will be one big mesh for each material which is GPU efficient but will use very very large amount of ram if for example i have 100 trees. OK?

If i got anywhere wrong please correct me.
Thanks for help .

So, basically, this thread to me seems like “Why is batching batching my geometry instead of instancing it?”

Well, if you want instanced geometry use instancing. Batched geometry cannot work any other way than how you’ve described it. One mesh needs to get sent to the GPU. What else can that mesh contain other than all of the data?

With instancing it’s different. There is no special SDK button for that. You will have to write code… and use 3.1.

1 Like

You still seem to have your old linked models in there btw.

Yes. in your video after batching, the linked models disappeared automatically. but in mine it did not . and i should delete them manually.

Actually I thought there may be some other techniques that i am not aware of them.
and Actually when creating this topic i did not know what is instancing . after reading @prog post i understand that what i am doing is called “Instancing”.
Anyway i learned something new today .
thanks for helps and sorry if my post seems foolish . :relaxed:

I’m not sure that you really do use instancing - real instancing was added only in 3.1 and as far as I know is yet not available in SDK editor, only from code.

Thanks. I am going to search more about instancing in this forum.

Yep. That’s right.

There is a new InstancedNode or something. Instancing is somewhere between ‘reusing the mesh’ and ‘batching’ in performance. It’s not as slow as separate objects and not as fast as batching… but uses roughly the same memory as multiple objects sharing a mesh.

1 Like

If I have tile based level, where I have floor tiles wall tiles and a tile is 1x1 this InstancedNode would speed up my scene right?

Depends on how big the tiles are. I mean, yes, it will speed up your scene… but so will batching. And batching may be better depending on the size of the tiles.

There is per-object overhead with instancing, it’s just pushed down to the driver. So, it’s good for things like trees… really really bad for things like grass.

I have 1x1 tiles, so relative small ones. I have to learn about batching, but guess if I have different materials batching is maybe not possible?
But yeah I will try then I see.

Instancing isn’t either, then.

You would batch or instance per material. Then you try to find ways to optimize down to fewer materials (like with texture atlases, etc.)

Generally, if you have separate 1x1 tiles it might be better to batch yourself and manage your own texture atlas and so on. For a tile based game, it ends up being the best way in the end.