Ejemplo n.º 1
0
        void SetupMaterial()
        {
            MMaterial InstanceMat = new MMaterial("InstanceGrassMaterial");
            MShader   shader      = new MShader("InstanceGrassShader");

            //shader.LoadFromString(sVertexShader, sFragmentShader);
            shader.Load("instanced_v.glsl",
                        "instanced_f.glsl",
                        "", ""
                        );
            shader.Bind();
            shader.SetFloat("Fade", 68);
            shader.SetInt("material.diffuse", MShader.LOCATION_DIFFUSE);
            shader.SetInt("material.specular", MShader.LOCATION_SPECULAR);
            shader.SetInt("material.multitex", MShader.LOCATION_MULTITEX);
            shader.SetInt("material.normalmap", MShader.LOCATION_NORMALMAP);
            shader.SetInt("material.shadowMap", MShader.LOCATION_SHADOWMAP);
            InstanceMat.AddShader(shader);
            MTexture GrassTex = Globals.TexturePool.GetTexture(TreeTexture);

            GrassTex._TextureWrapMode = TextureWrapMode.ClampToBorder;
            GrassTex.DoAssign         = true;
            InstanceMat.SetDiffuseTexture(GrassTex);
            this.SetMaterial(InstanceMat);
            grass.SetMaterial(InstanceMat);
            MScene.MaterialRoot.Add(InstanceMat);
        }