public Effect(EffectData effectData) { Name = effectData.Name; CBufferLinks = new List<CBufferLink>(); ConstantBuffers = new Dictionary<string, EffectConstantBuffer>(); Parameters = new Dictionary<string, EffectParameter>(); foreach (CBufferLinkData cb in effectData.CBuffers) { EffectConstantBuffer cBuffer = MaterialManager.ConstantBuffers[cb.CBuffer]; ConstantBuffers.Add(cb.CBuffer, cBuffer); CBufferLinks.Add(new CBufferLink() { CBuffer = cBuffer, Slot = cb.Slot }); foreach (EffectParameter parameter in cBuffer.Parameters.Values) { Parameters.Add(parameter.Name, parameter); } } Techniques = new Dictionary<string, EffectTechnique>(); foreach (TechniqueData td in effectData.Techniques) { TechniqueTags tags = new TechniqueTags(td.Tags); EffectTechnique technique = new EffectTechnique(td.Name, tags,this); Techniques.Add(td.Name, technique); SetCurrentTechnique(td.Name); technique.Passes = new List<EffectPass>(); foreach (PassData pd in td.Passes) { EffectPass pass = new EffectPass(pd.Rasterizer, pd.Blend, pd.DepthStencil, pd.Shader, pd.VertexShaderEntryPoint, pd.PixelShaderEntryPoint, tags, this); technique.Passes.Add(pass); } } WorldMatrix = Parameters["world"]; ViewMatrix = Parameters["view"]; ProjectionMatrix = Parameters["projection"]; WolrdInverseTrasposeMatrix = Parameters["worldInverseTraspose"]; EyePos = Parameters["eyePos"]; }
public void SetCurrentTechnique(string name) { CurrentTechnique = Techniques[name]; }