hi,
i’d like to know what is meant by “batch rendering”. i’ve read several sites online (including that), couldn’t figure it out. what i learnt is to optimize drawing, i have to reduce state changes and drawcalls as well as cpu <–> gpu data transfers (like uploading bufferdata, uniforms etc). and of course eliminate (implicit) syncronization when downloading data wherever possible.
currently i’m using 1 VAO + VBO for all model meshes, and 1 progam (phong) to shade meshes, and sorting my stuff like that:
/* to draw 1 mesh */
struct DrawArrays {
GLenum Mode;
GLint First;
GLsizei Count;
};
struct RenderState {
bool WireFrame; /* for glPolygonMode() */
bool TwoSided; /* for culling */
bool Blending; /* for "simple" transparency */
};
struct MaterialData {
vec3 Ambient, Diffuse, Specular, Emissive;
float Shininess;
};
struct Material {
RenderState State;
MaterialData Data;
};
/* to draw 1 model */
struct ModelInstance {
/* location, orientation, size */
mat4 Transformation;
/* currently sorted by material */
list< pair<Material, vector<DrawArrays>> > Components;
/* later i'll add bones */
};
all the “Components” for a model instance are generated once when i initialize the application and are then stored.
so what i’m trying to do is to only upload materialdata once, and draw all meshes that use this material. later i’m trying to map them to renderstates to reduce GL state changes and maybe but all these drawcommands into a GL_DRAW_INDIRECT_BUFFER do reduce them to 1 “drawcommand”.
is this a kind of “batch rendering” (since i’m sort of “batching” drawcalls) or am i missing something? or is instanced rendering meant by “batching”?
thanks.