Material, Pass, Technique and shaders

Posted by Papi75 on Game Development See other posts from Game Development or by Papi75
Published on 2013-10-16T09:29:33Z Indexed on 2013/10/17 16:27 UTC
Read the original article Hit count: 294

I'm trying to make a clean and advanced Material class for the rendering of my game, here is my architecture:

class Material
{
    void sendToShader()
    {
        program->sendUniform( nameInShader, valueInMaterialOrOther );
    }

private:

    Blend       blendmode;      ///< Alpha, Add, Multiply, …
    Color       ambient;
    Color       diffuse;
    Color       specular;
    DrawingMode drawingMode;    // Line Triangles, …
    Program*    program;
    std::map<string, TexturePacket> textures;   // List of textures with TexturePacket = { Texture*, vec2 offset, vec2 scale}
};
  • How can I handle the link between the Shader and the Material? (sendToShader method)
  • If the user want to send additionals informations to the shader (like time elapsed), how can I allow that? (User can't edit Material class)

Thanks!

© Game Development or respective owner

Related posts about opengl

Related posts about architecture