My E/C implementation is the basic one where Entities are just ID's, Components are data and Systems act on the Data. Right now I'm having trouble with object materials and rendering in general. For simple objetcs I have a ModelComponent
, tied to a RenderSystem
, ModelComponent
has the vertex buffer ids that the render system uses. A simple MaterialComponent
would probably have color or specular strenght, etc, but I wanted it to be flexible enough to allow for more than one render pass and general "effects" that are not as easy as a simple variable in the MaterialComponent
.
Trying to solve these problems I came up with two solutions:
1 - Super-generic Material Component
Something like this:
struct Material : public Component
{
ShaderData* shader;
std::vector<std::pair<std::string, boost::any>> uniforms;
[...]
};
and in the render system I would loop and pass the uniforms to the shader. I suppose this would be slow, but fast enough for my purposes.
2 - Another layer of abstraction, MaterialData
Having a class to wrap specific materials, that could be inherited by whatever specialized material, the base class would have something like void set_shader_constants(ShaderData* d)
but the implementation is up to each class, and the MaterialComponent
would have a pointer to a MaterialData object.
I'm not sure which approach I would prefer, but neither of these touch the subject of multiple passes, or other complex rendering techniques.
Any idea on how to accomplish this?