Instance Batch Rendering
Instance Batch Rendering (IBR) is a name I dubbed for a lighter-weight method of handling and rendering multiple Object3D's of the same Mesh. Android applications need to be optimized for limited memory and speed. This method will help increase the speed of the rendering process with a lighter footprint, but requires work on your-end as well. IBR relies on GLSL, and does support bones using a hybrid GPU method. Features of jPCT may not be available for IBR.
Example uses of IBR might be:
- an RTS with multiples of the same model;
- an FPS with multiple enemies of the same model;
- rendering trees on terrain;
I have added notes and personal recommendations. This architecture may not be perfect for your project, so please alter and use to fit your needs.
Comments and suggestions are welcome as I will be adding a FAQ to the bottom of the page.
- JPCT (requires GL ES 2+ as it uses GLSL Shaders)
How It Works
IBR works by only creating and adding one Object3D to the world for a given Mesh that can be rendered any number of times. This Object3D is always positioned in-front of camera so it is always picked up in the render pipeline (handled by the InstanceManager on update). A lighter-weight InstanceObject3D class is used instead of an Object3D for the instance's position, rotation, scale, and object type (reference to the Object3D's mesh). An IRenderHook is attached to the Object3D, which ties into jPCT's render pipeline. When the Object3D is rendered, it will loop X number of times through the render call for each instance. Each time calculating the ModelViewMatrix of your Instance3D and passing it into the GLSL Shader.
Gains: XX Losses: XX
This code is free, open-source code and you are welcome to use it as you see fit.
How to Use the Code
To be written