Пример #1
0
        private ShaderManager()
        {
            string frag = ReadFromAssetStream(defPath + "def.fsh");
            string vert = ReadFromAssetStream(defPath + "def.vsh");

            shaderDictionary = new Dictionary <string, Shader>();
            Shader def = new ShaderMain(vert, frag);

            shaderDictionary.Add("def", def);
        }
Пример #2
0
        static BackgroundSkybox()
        {
            string path = "shaders.";
            string vs   = ResourcesManager.ReadFromInternalResource(path + "Skybox.vsh");
            string fs   = ResourcesManager.ReadFromInternalResource(path + "Skybox.fsh");

            backgroundShader = new ShaderMain(vs, fs);
            backgroundShader.ApplyShader();
            backgroundShader.SetUniform(0, "skybox");
        }
Пример #3
0
        public Shader LoadShader(string name, string vert, string frag)
        {
            if (shaderDictionary.ContainsKey(name))
            {
                return(shaderDictionary[name]);
            }
            Shader shdr = new ShaderMain(vert, frag);

            shdr.ApplyShader();
            shdr.SetUniform(0, "material.texture_difuse");
            shdr.SetUniform(1, "material.texture_toon");

            shdr.SetUniform(10, "shadowMap");

            shaderDictionary.Add(name, shdr);

            return(shdr);
        }
Пример #4
0
        Shader Creator()
        {
            Shader shdr = null;

            try
            {
                shdr = new ShaderMain(rawVertex, rawFragment);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e.Source);
            }

            //binding buffers
            var ubm = UniformBufferManager.GetInstance;
            var ubs = ubm.GetBuffer("skeleton");

            shdr.SetUBO(ubs.BufferIndex, "skeleton");
            var ubsp = ubm.GetBuffer("space");

            shdr.SetUBO(ubsp.BufferIndex, "space");
            var ubl = ubm.GetBuffer("light");

            shdr.SetUBO(ubl.BufferIndex, "light");

            var ubsy = ubm.GetBuffer("system");

            shdr.SetUBO(ubsy.BufferIndex, "system");

            //bind textures
            shdr.ApplyShader();

            shdr.SetUniform((int)TextureType.ShadowMap, "shadowMap");
            shdr.SetUniform((int)TextureType.Diffuse, "material.texture_diffuse");
            shdr.SetUniform((int)TextureType.Toon, "material.texture_toon");
            shdr.SetUniform((int)TextureType.Specular, "material.texture_specular");
            shdr.SetUniform((int)TextureType.Sphere, "material.texture_spere");

            return(shdr);
        }