   Comments on my effect system
  HelloI'm trying to implement an effect system for my 3d engine. My render-loop looks like this:// loop through each effectforeach(KeyValuePair<Effect, Dictionary<EffectParameters, VertexChunk>> effectDict in renderList){ Effect effect = effectDict.Key;// render effectint passes = effect.Begin();for(int i = 0; i < passes; ++i){// start effect passeffect.BeginPass(i);// loop through each geometry with effect parametersforeach(KeyValuePair<EffectParameters, VertexChunk> paramChunk in effectDict.Value){// set effect parameterseffect.SetParameters(paramChunk.Key);// draw geometryparamChunk.Value.Draw();}// end effect passeffect.EndPass();}effect.End();}The render-list is composed by vertex chunks with effect parameters sorted by effect. The EffectParameters class is not implemented yet but it will contain information about technique to use, shader constants and texture to set. Is there any flaws in this design? Is this a good base for an effect system? Any tips on how to implement the EffectParameters class?ThanksOpwiz   
  You should only submit one draw call per pass, not per parameter.  Also you will have to call effect.CommitChanges() in this situation before the draw call.  If you set the parameters before the effect.Begin() then you do not have to do this.Once you get this stuff working you should setup a shared parameter system, where you set it once and it is replicated to all effects in the same pool.  This is useful for a ton of paramters, like camPos, where the value doesn't change between objects.After that you should setup a render pass system.  Not passes on individual objects, as you have now, but the ability to render any subset of the scene and specify the render target, and then use that render target later.  This is necessary for tons of advanced effects like shadow mapping, dynamic reflections and post processing.   ;Quote:Original post by jameswYou should only submit one draw call per pass, not per parameter.  Also you will have to call effect.CommitChanges() in this situation before the draw call.  If you set the parameters before the effect.Begin() then you do not have to do this.The Effect class in the previous post is wrapping the direct3d effect class and the idea is that the SetParameters() method is to set all parameters related to a certain vertex chunk (e.g. texture, transform, etc) - and in doing so calling appropriate methods on the direct3d effect class including CommitChanges(). Quote:Once you get this stuff working you should setup a shared parameter system, where you set it once and it is replicated to all effects in the same pool.  This is useful for a ton of paramters, like camPos, where the value doesn't change between objects.I suppose I need another level in the render-list so it becomes:|- Effect 1||- Shared Parameters 1||  |- Parameters 1 + vertex chunk 1||  |- Parameters 2 + vertex chunk 2||- Shared Parameters 2|   |- Parameters 3 + vertex chunk 3|- Effect 2||- Shared Parameters 3  .    .  .    .  .    .Does this make sense? So when a renderable object becomes visible and is to be drawn it puts its vertex chunks in the render-list:renderList.Add(effect, sharedParameters1, parameters1, chunk1);renderList.Add(effect, sharedParameters1, parameters2, chunk2);renderList.Add(effect, sharedParameters2, parameters3, chunk2);renderList.Add(effect2, sharedParameters3, parameters4, chunk4);  ...It becomes a bit complicated though if say 5 renderable objects has some shared parameters that includes camera position, who is responcible for updating the parameter? Perhaps it would be a nice idea if the shared parameter just points to the variable that is supposed to be shared.Quote:After that you should setup a render pass system.  Not passes on individual objects, as you have now, but the ability to render any subset of the scene and specify the render target, and then use that render target later.  This is necessary for tons of advanced effects like shadow mapping, dynamic reflections and post processing.Unless this does'nt completely break my design I'd prefer not to think about it until I'll need to implement it.. :)Thanks for your reply.