Right now Panda 3D supports hardware instancing, but it is agnostic of the scene graph and thus of bounding volumes, culling, collisions and maybe something else.
I am exploring the options how to add a new “hardware instanced” render attribute to a node path and make the graphics pipeline respect it. If I understand correctly, it should be something like this:
- If the CullTraverser visits the same GeomNode with the “hardware instanced” attribute twice (either if it is a reference set by user, or a recursive traversal) or more, it shouldn’t add this Geom to the cull result, but rather store the instance ID and transform data in some kind of container.
- At the same time, GraphicsStateGuardian should somehow update the shader attribute with each node’s transofrm.
- GeomPipelineReader should read this data and make the GraphicStateGuardian dispatch a correct call (glDrawArraysInstanced or glDrawElementsInstanced, since OpenGL is a primary backend)
- Preferably, the ShaderGenerator should add an input with array of node transforms so the user could do without writing own shaders.
- Don’t know if it will work with the fixed pipeline, but I think it’s not important
Said all that, I have the following questions to the people who know how the render pipeline functions:
- Is my understanding is correct?
- How much work be needed for this?
- Does it worth implementing at all, or the performance bottleneck will be somewhere else? E.g. if we still traversing 1000 nodes and then drawing with 1 call, it will take more time than to draw instances in 1000 calls without scene graph traversing?