How does instancing work?

Hello everyone,
I was trying to understand how rendering is done in Babylon, but got a bit confused by its pipeline.
It’s how I see it working right now:

Firstly there is something like preparation stage when we create submesheshes for each mesh that should be rendered. Basically submesh stores reference to the mesh and a “rendering” mesh (which is the LOD of the parent mesh in case the “source” mesh instantiated).

Then submesh passed to the rendering manager and attached to a group.

During rendering stage, each submesh is called to be drawn and that plainly calls “rendering” mesh to be drawn.

From this point I think I am missing something because when render() method called it renders mesh and its instances either and as far as there can be many submeshes referring to the same “rendering” mesh it would rerender meshes.

As it can’t be true my question is where I made a mistake.

Perhaps I am wrong in some other moments (or even completely wrong) so I will be very thankful for any response.

May be this will help you to have better understanding ot this topic

Hi avin,
I am sorry for an ambiguous explanation. My problem is that I understand how low-level rendering is done but I have no clue how meshes are being prevented from being redrawed multiple times per frame. It is not the WebGL thing but more about how batching is done.

PS Thank you for the link, back in the days I was looking for something like that. I think it might be useful for some people willing to learn GL API.

Well, I realized that only “parent” (regular) meshes are added to rendering group.
I apologize if I confused anyone by my wrong interpretation.

1 Like