Hi,
Currently my engine only supports instancing in a few limited cases, and I'm trying to fix that by implementing a more generic system.
When do engines usually find objects that can be instanced? Dynamically every frame after culling? Or at a "higher-level" by keeping a list of objects that use the same model?
Currently my scene struct looks like this:
struct Scene
{
uint num_actors;
InstanceData* actors_instance_data;
uint* actors_node_handles; //handles of actors' scene graph node(used to get world matrix)
Model** actors_models;
BoundingSphere** bounding_spheres;
};
I could do it every frame after culling, by sorting the actors by model and if two actors a and b use the same model (actors_models[a] == actors_models[b]) then they can be instanced by copying actors_instance_data[a] and actors_instance_data[b] to a constant buffer.
Does this seem reasonable or should I go with a "higher level" option?
Thanks.