Hi everyone!
In my system, I have MaterialDefinition which points to a ShaderProgram and a list of ShaderParameters that the Shader needs. This type of resource is shared, meaning that there is only instance of MaterialDefinition and the ShaderParameters don't contain any value. These are fetched from Material instances. Each Renderable has its own Material Instance, and this way, I can animate Materials in different renderables without affecting other renderables.
How would you go about implementing a RenderQueue with key (i.e.: 64-bit integer) based sorting where some of the bits are based on the Material ID and have Material Animation on some of its parameters (animating the colours). The big issue here is that the RenderQueue assumes that Materials with the same ID have exactly the same parameter values so that the number of render commands is reduced but with animation it becomes harder.
Creating a key based on the Material Definition would allow me to reduce the number of times I change shaders. Creating a key based on the Material would allow me to reduce shader, textures and parameters changes. However, if I have animations, then each renderable could potentially have different material IDs and would defeat the whole purpose.
How would you solve a situation like this?