@Nik02: Thanks for your answer, but they did not fit 100% to my question;)
I did not ask about variables shared across different effect files. I asked about how to handle variables that are shared across different TECHNIQUES in one effect file (see my code).
But my main problem stays: Every technique is different. One needs a float3 lightDir, the other technique a float exposure and so on. I wonder how I can treat all the different techniques. If I have one Technique class for all techniques, I cant give the class member variables that reflect the shader constants of that technique. For example I cant just write this:
class Technique {public: ID3D10EffectScalarVariable* exposure;};
because most of my techniques dont need the exposure. Currently I can just imagine two solutions: A) Having ONE Technique class, which holds NO shader variables as member. To set a constant I need to do something like this:
class Technique {public: ID3D10Effect* effect; void setScalarConstant(string name, float val) { effect->GetVariableByName(name)->AsScalar()->SetFloat(val); } // Similar functions setMatrixConstant() and so on...};
The problem with this approach: On every update I call 3 functions (GetVariableByName, AsXX, SetYY) for all constants. I don't know how expensive these calls are, but I don't have a good feeling with this approach. I would strongly prefer just calling scalarVar->setFloat(val); But again this isnt possible if I have ONE Technique class that handles every technique.
B) My second idea is to have a base class Technique and for EVERY technique in an effect file I create a subclass, that has the appropriate shader variables for this technique:
class TechniqueDiffuse : public Technique {public: ID3D10EffectScalarVariable* exposure; ID3D10EffctMatrixVariable* world;};
Now I can just call techniqueDiff->exposure->setFloat(val);
I neither like the first nor the second idea. I dont like the first idea because I don't want to call 3 functions to update a shader constant. And I don't like the second idea because this would lead to a lot of classes...
I hope you understand my problem. What do you think of these approaches? How do you handle it?