Difference between revisions of "Instance Batch Rendering"

From JPCT
Jump to: navigation, search
Line 1: Line 1:
 
 
== Overview ==
 
== Overview ==
 
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.
 
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.
Line 20: Line 19:
 
<li>jPCT (requires GL ES 2+ as it uses GLSL Shaders)</li>
 
<li>jPCT (requires GL ES 2+ as it uses GLSL Shaders)</li>
 
</ul>
 
</ul>
 +
  
 
== How It Works ==
 
== How It Works ==

Revision as of 22:37, 13 July 2016

Overview

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;
  • etc...

I have added notes and personal recommendations. This architecture will most likely 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.


Requirements

  • 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 object 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 as a uniform.

Gains: Speed: IBR taps into the jPCT's render pipeline to batch render all instances of a model synchronously. Memory Usage: lighter footprint per multiple instances.

Losses: Many niceties that the Object3D offers: different texture data per model, octrees, etc... (These features will not come stock)

Using IBR, you will be responsible for determining if each instance is visible by the camera. If there are no visible instances, the InstanceManager will automatically set the Object3D visibility to false, so it does not get added to the render visibility list.


The Code

This code is free, open-source code and you are welcome to use it as you see fit.


XXX Class:



How to Use the Code

  • XXX


FAQ

To be written