Esempio n. 1
0
        public Program(string name, HighLevelGpuProgram vs, HighLevelGpuProgram ps,
                       IEnumerable <VariableDescription> samplers)
        {
            VertexShader = vs;
            PixelShader  = ps;

            LogManager.Instance.Write("VS:");
            LogManager.Instance.Write("================================================================================");
            LogManager.Instance.Write(vs.Source);
            LogManager.Instance.Write("PS:");
            LogManager.Instance.Write("================================================================================");
            LogManager.Instance.Write(ps.Source);

            var mm = MaterialManager.Instance;

            Material = (Material)mm.Create(name, "SLSharp");
            var mat = Material;

            mat.RemoveAllTechniques();
            _tech            = mat.CreateTechnique();
            _tech.SchemeName = "SLSharp";
            _tech.RemoveAllPasses();
            Pass = _tech.CreatePass();
            if (vs != null)
            {
                Pass.SetVertexProgram(vs.Name);
            }
            if (ps != null)
            {
                Pass.SetFragmentProgram(ps.Name);
            }

            foreach (var s in samplers)
            {
                var tu = Pass.CreateTextureUnitState();
                tu.Name = s.Name;
                _textureUnits.Add(s.Name, tu);
            }

            Pass.LightingEnabled = false;
            mat.Load();

            MatToProg.Add(mat, this);
        }