Beispiel #1
0
        public MagicBackground()
        {
            shader = new Shader();

            float v = Shader.Version;

            shader.LoadVertexFile(Path.Combine("Effects", v < 3.3f ? "v12" : "v33", "magic_background.vert"));
            shader.LoadFragmentFile(Path.Combine("Effects", v < 3.3f ? "v12" : "v33", "magic_background.frag"));

            shader.Link();

            buffer = new VertexBuffer(4);
            buffer.DeclareNextAttribute("vposition", 2);
            buffer.DeclareNextAttribute("vtexcoord", 2);
            buffer.DeclareNextAttribute("vcolor", 4);

            buffer.Attach(shader);

            buffer.AddVertex(-1, -1, 0, 0, 1f, 1f, 1f, 1f);
            buffer.AddVertex(1, -1, 1, 0, 1f, 1f, 1f, 1f);
            buffer.AddVertex(1, 1, 1, 1, 1, 1, 1, 1);
            buffer.AddVertex(-1, 1, 0, 1, 1, 1, 1, 1);
            buffer.AddIndices(0, 1, 2, 0, 2, 3);
            buffer.UpdateBuffer();
        }
Beispiel #2
0
        public void Init()
        {
            blood_blend_shader = new Shader();

            float v = Shader.Version;

            blood_blend_shader.LoadVertexFile(Path.Combine("Effects", v < 3.3f ? "v12" : "v33", "blood_blend.vert"));
            blood_blend_shader.LoadFragmentFile(Path.Combine("Effects", v < 3.3f ? "v12" : "v33", "blood_blend.frag"));

            blood_blend_shader.Link();

            blend_buffer = new VertexBuffer(4);
            blend_buffer.DeclareNextAttribute("vposition", 2);
            blend_buffer.DeclareNextAttribute("vtexcoord", 2);
            blend_buffer.DeclareNextAttribute("vcolor", 4);

            blend_buffer.Attach(blood_blend_shader);
            blend_buffer.AddVertex(-1, -1, 0, 0, 1f, 1f, 1f, 1f);
            blend_buffer.AddVertex(1, -1, 1, 0, 1f, 1f, 1f, 1f);
            blend_buffer.AddVertex(1, 1, 1, 1, 1, 1, 1, 1);
            blend_buffer.AddVertex(-1, 1, 0, 1, 1, 1, 1, 1);
            blend_buffer.AddIndices(0, 1, 2, 0, 2, 3);
            blend_buffer.UpdateBuffer();
        }
Beispiel #3
0
        private static void LoadMaterials(XmlNode main)
        {
            XmlNode material = main.SelectSingleNode("Materials");
            XmlNodeList materials = material.SelectNodes("Material");
            string basePath = material.Attributes["basePath"].Value;

            foreach (XmlNode item in materials)
            {
                string name = item.Attributes["gameName"].Value;
                string vshader = item.Attributes["vshader"].Value;
                string fshader = item.Attributes["fshader"].Value;

                XmlNodeList @params = item.SelectNodes("Param");

                Shader shader = new Shader();
                shader.LoadVertexFile(basePath + "//" + vshader);
                shader.LoadFragmentFile(basePath + "//" + fshader);
                shader.Link();
                Material mat = new Material(shader);
                foreach (XmlNode param in @params)
                {
                    string paramName = param.Attributes["name"].Value;
                    string paramType = param.Attributes["type"].Value;
                    string paramValue = param.Attributes["value"].Value;

                    mat.SetParameter(paramName, paramType, paramValue);
                }

                _materials[name] = mat;
            }
        }