Contents

Overview

Instance Batch Rendering (IBR) is a name I (alias Redman) 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.

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.

package yourpackagename.instances;
import com.threed.jpct.Camera;
import com.threed.jpct.Object3D;
/**
* Created by Dougie on 7/6/16.
*/
public interface IInstanceManagerHelper {
//Method is called to create an instance of pType with its respective InstanceObjectRenderer
public InstanceObject3D spawn(short pType, InstanceObjectRenderer pRenderer);
//Method is called to create an Object3D / Animated3D of pType.
public Object3D fetchObject3D(short pType);
//Method is called during update to see if an InstanceObject3D is visible by the camera
public boolean checkVisibility(InstanceObject3D pIO3D, Camera pCamera);
//Method is called on destruction / clearing of the InstanceManager
public void onDestroy();
}