I make a voxel engine on LWJGL 3 (OpenGL binding for JVM). I store all object data in world class. World is subdivided into 32*32*32 chunks. Chunks use octree storage. The main part of all my rendering is cubes that share one mesh but have different transformation matrices and some other data. To render those i use one VAO per chunk, it contains only one cube mesh instance and has all cubes data (like transformations) stored in its VBOs. I construct each chunk VAO once and render it fully in one call - glDrawElementsInstanced. If i need to change some cube data in a chunk, i will reconstuct VAO from ground up or change individual buffer data. That should be pretty efficient, right ?
But I need some other stuff to be rendered, like complex mesh objects or effects or some debug stuff.
How should I render those objects ? Should I create a VAO for each mesh and then perform instanced rendering for each object with the same mesh ? Or should I batch all objects with their meshes into one VAO for each chunk and render it fully ?
I was trying to create a VAO recently, that contained one instance of each mesh and all object data. But i could not render it correctly. Because each time I needed to somehow switch object data VBO while rendering an instanced mesh. It didn't work.
Code for the last VAO: http://pastebin.com/WanNsR5L