• Create Account

### #ActualBitMaster

Posted 07 November 2012 - 09:13 AM

I don't have a lot of experience on mobile platforms, but shouldn't the glDraw*Instanced family of calls solve your problem? You have one VBO containing the box geometry. In your shader you then have something like this
#define MAX_INSTANCE SomeReasonableValue

uniform mat4 mvp[MAX_INSTANCES];
...
outVertex = mvp[gl_InstanceID] * inVertex;

The only bottleneck (that is, the number of glDraw*Instanced calls required to draw N boxes) there will be how much space you have for uniforms. If you are limited to certain kinds of transformations (for example only translations, uniform scale and/or rotations around one axis) for the boxes you could try to send only those parameters to the program and building an instance-specific matrix on the fly. Of course building that matrix for every vertex might well be more costly than setting the larger uniform matrices. However, if you are limited to translations only this could be better:
uniform mat4 mvp;
uniform vec3 translations[MAX_INSTANCES];
...
outVertex = mvp * (inVertex + vec4(translations[gl_InstanceID], 0));


### #1BitMaster

Posted 07 November 2012 - 09:12 AM

I don't have a lot of experience on mobile platforms, but shouldn't the glDraw*Instanced family of calls solve your problem? You have one VBO containing the box geometry. In your shader you then have something like this
#define MAX_INSTANCE SomeReasonableValue

uniform mat4 mvp[MAX_INSTANCES];
...
outVertex = mvp[gl_InstanceID] * inVertex;

The only bottleneck (that is, the number of glDraw*Instanced calls required to draw N boxes) there will be how much space you have for uniforms. If you are limited to certain kinds of transformations (for example only translations, uniform scale and/or rotations around one axis) for the boxes you could try to send only those parameters to the program and building an instance-specific matrix on the fly. Of course building that matrix for every vertex might well be more costly than setting the larger uniform matrices. However, if you are limited to translations only this could be better:
uniform mat4 mvp;
uniform vec3 translations[MAX_INSTANCES];
...
outVertex = mvp * (inVertex + translations[gl_InstanceID]);


PARTNERS