Exemplo n.º 1
0
        public EffectPass(string rasterizer, string blend, string depthStencil,
            string shader, string vertexEntryPoint, string pixelEntryPoint, 
            TechniqueTags tags, Effect effect)
        {
            if (rasterizer != "")
            {
                _hasRasterizerState = true;
                _rasterizerState = MaterialManager.RenderStates.GetRasterizerState(rasterizer);
            }

            if (blend != "")
            {
                _hasBlendState = true;
                _blendState = MaterialManager.RenderStates.GetBlendState(blend);
            }

            if (depthStencil != "")
            {
                _hasDepthStencilState = true;
                _depthStencilState = MaterialManager.RenderStates.GetDepthStencilState(depthStencil);
            }

            _tags = tags;

            _shader = new Shader(shader, tags, true, pixelEntryPoint, vertexEntryPoint);
        }
Exemplo n.º 2
0
        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"];

        }
Exemplo n.º 3
0
        public Shader(string name, TechniqueTags tags, bool allowDynamicCompilation,
            string pixelShaderEntryPoint = "PixelShader", string vertexShaderEntryPoint = "VertexShader")
        {
            _name = name;
            _tags = tags;

            _path = SHADERS_PATH + _name + SHADERS_EXTENSION;

            _pixelShaderEntryPoint = pixelShaderEntryPoint;
            _vertexShaderEntryPoint = vertexShaderEntryPoint;

            if (!allowDynamicCompilation)
                Compile();
            else
                _compiled = false;
        }
Exemplo n.º 4
0
 public EffectTechnique(string name, TechniqueTags tags, Effect effect)
 {
     Name = name;
     _tags = tags;
     _effect = effect;
 }