I'm trying to implement a Material system in a small engine for training and I've got questions about materials.
Currently I've got that:
- Material: A Material with array of Technique
- Technique: Stock an array of Pass
- Pass: Content RenderState (blend to apply, draw mode, face culling, …), Shader/Program and an array of Parameter
- Geometry: Buffers, Indices, Vertices, ….
- Parameter: A parameter is use to stock and share values with program (color, texture,…)
Now I'm not sure about that:
A Material is something shared by Meshes or each Mesh have his own Material? In my scene, I've got 5 trees: two red trees and 3 blue shiny red trees (same Geometry). Each tree have is own Material or each tree have a reference to the same Material?
The Material own by a Mesh is a copy of a Material or a reference to the original Material?
In my Material I have texture offset and scale, it's useful for drawing a part of the Texture only, but how can I manage offset and scale if my Material is shared and each owner didn't use the same values? (In the case where all my objects are in the same texture atlas)
If each mesh have his own Material instance (a copy of an original Material) how can I know if each Mesh have the same Material? (An ID per Material may be?)
Thanks a lot!