Instancing Revisited -- Owen Meyers

     In the previous blogpost, I discussed the Instancing manager that needed to be put together in order to properly display static meshes. The system was essentially a pool for the instances on the CPU side, which would then be organized and sent over to the GPU. There were some problems with building this system, which led to a bit of a longer development cycle on this feature than I would've wanted, however it was still completed on time.

    The first problem that I encountered when building this system was integration. The way I approached this problem was simply by removing all instancing from the Central Processing system, and instead place it within its own manager. This helped to simplify a lot of the update code, as a message would be received in Central Processing to update a model or add/remove an instance. That message would simply be passed along to the Instancing Manager, which allowed for a "black box" approach to utilization. Anybody from anywhere within the engine, should they so need, would simply need to send a message with the proper data (usually a model name and an object pointer) in order to generate the instance. The system would then process the command and keep a registry of objects that are active, allowing for the system to easily update any object on where it appears in the buffer.

    The second problem that I encountered when building this system was the data organization system itself. The approach I had been using up until this point was a copy of the animation manager system. This, however, didn't account for how the buffer had to be laid out for the actual instances of meshes. The reason for this is that the animation manager uses a disorganized buffer that is organized by the instancing buffer. This means that I was building the system the animation manager uses to inform its organization *using the organizational system of the animation manager.* This required a shift in thinking, that ultimately took a few days in order to fully build. The result was an instance manager that was capable of organizing the data given to it, provided those outside of the system utilized it properly.

The striking difference between adding an instance of an animation state machine (left) and a skinned mesh (right). The system on the right is split between skinned and static meshes as the buffer is split in two before being merged.


The result of the final system. Meshes are stamped out in batches on the GPU rather than being individually drawn.


Comments

Popular posts from this blog

Adding assets to every enemy -- Owen Meyers

Sphere to AABB collision