I'm trying to understand in detail how to program a render queue, in
particular the way L. Spiro has explained in several posts.
This is what I think she has said:
Each camera and light that cast shadows has a render queue set.
A render queue set is composed of two render queues, one for opaque
submeshes and one for alpha submeshes:
class Render_queue_set {
Render_queue opaque_queue;
Render_queue alpha_queue;
};
A render queue is a sequence (array, vector, etc.) of render items.class Render_item {
Model *model; // Not sure
Mesh *mesh; // Not sure
Submesh *submesh; // Not sure
Shader_id shader_id;
int num_textures;
Texture_id textures[MAX_TEXTURE_UNITS];
float depth; // Distance from model (or mesh?) to the camera
};
Render procedure for each viewpoint:- The Scene Manager collects models than are in view (frustrum culling,
occlusion culling, etc.).
- Tell each collected model to push items to the render queue set.
- Sort the render queues.
- Sort only indices.
- Take advantage of per-frame temporal coherence.
- For each render item in the render queues (first opaque and second
alpha) tell the mesh (or model?) to render the item.
I'm not sure if a render item of the L. Spiro design needs pointers to model,
mesh and/or submesh. In my current engine, I would need the three pointers because:
- The model has the matrices I need to set uniforms.
- The mesh has the vertex buffer (I share the same vertex buffers for all
submeshes) and currently a submesh doesn't have a pointer to his mesh.
- Each submesh has the index buffer and the material.