예제 #1
0
        public LCC3ShaderAttribute(LCC3ShaderProgram program, LCC3VertexAttrIndex attrIndex)
            : base(program, (int)attrIndex)
        {
            switch (attrIndex)
            {
                case LCC3VertexAttrIndex.VertexAttribPosition:
                    this.Semantic = LCC3Semantic.SemanticVertexLocation;
                    break;
                case LCC3VertexAttrIndex.VertexAttribNormal:
                    this.Semantic = LCC3Semantic.SemanticVertexNormal;
                    break;
                case LCC3VertexAttrIndex.VertexAttribColor:
                    this.Semantic = LCC3Semantic.SemanticColor;
                    break;
                case LCC3VertexAttrIndex.VertexAttribTexCoords:
                    this.Semantic = LCC3Semantic.SemanticVertexTexture;
                    break;
            }

            this.Location = attrIndex;
        }
예제 #2
0
 public LCC3ShaderUniform(LCC3ShaderProgram program, int index)
     : base(program, index)
 {
 }
예제 #3
0
 public static LCC3ShaderUniform VariableInProgram(LCC3ShaderProgram program, int index)
 {
     return new LCC3ShaderUniform(program, index);
 }
예제 #4
0
        private void InitializeMaterialShader()
        {
            _progPipeline.EnableVertexAttributeAtIndex(true, LCC3VertexAttrIndex.VertexAttribPosition);
            _progPipeline.EnableVertexAttributeAtIndex(true, LCC3VertexAttrIndex.VertexAttribNormal);
            _progPipeline.EnableVertexAttributeAtIndex(true, LCC3VertexAttrIndex.VertexAttribTexCoords);
            //_progPipeline.EnableVertexAttributeAtIndex(true, LCC3VertexAttrIndex.VertexAttribColor);

            LCC3ShaderProgramMatchers programMatchers = new LCC3ShaderProgramMatchers();
            _materialShaderProgram = programMatchers.ConfigurableProgram();
        }
예제 #5
0
        private void InitializeTankEffect()
        {
            _tankShader = new LCC3ShaderProgram(0, "MyShader", this, "Content/BasicEffect.ogl.mgfxo");
            _tankTexture = new LCC3GraphicsTexture2D("turret_alt_diff_tex_0");
            _tankShader.XnaShaderEffect.CurrentTechnique = _tankShader.XnaShaderEffect.Techniques[21]; //5

            LCC3ShaderUniform textureUniform = _tankShader.UniformNamed("Texture");
            textureUniform.SetValue(_tankTexture);
            textureUniform.UpdateShaderValue();

            LCC3ShaderUniform diffuseColorUniform = _tankShader.UniformNamed("DiffuseColor");
            LCC3Vector4 diffuseColor = new LCC3Vector4(1.0f, 1.0f, 1.0f, 0.4f);
            diffuseColorUniform.SetValue(diffuseColor);
            diffuseColorUniform.UpdateShaderValue();

            LCC3ShaderUniform emissiveColorUniform = _tankShader.UniformNamed("EmissiveColor");
            LCC3Vector emissiveColor = new LCC3Vector(0.5f, 0.5f, 0.9f);
            emissiveColorUniform.SetValue(emissiveColor);
            emissiveColorUniform.UpdateShaderValue();

            LCC3ShaderUniform specularColorUniform = _tankShader.UniformNamed("SpecularColor");
            LCC3Vector specularColor = new LCC3Vector(1.0f, 0.0f, 0.0f);
            specularColorUniform.SetValue(specularColor);
            specularColorUniform.UpdateShaderValue();

            LCC3ShaderUniform specularPowerUniform = _tankShader.UniformNamed("SpecularPower");
            float specularPower = 100.0f;
            specularPowerUniform.SetValue(specularPower);
            specularPowerUniform.UpdateShaderValue();

            LCC3ShaderUniform light0DirectionUniform = _tankShader.UniformNamed("DirLight0Direction");
            LCC3Vector light0Direction = (new LCC3Vector(-0.5f, -1.2f, -1.0f)).NormalizedVector();
            light0DirectionUniform.SetValue(light0Direction);
            light0DirectionUniform.UpdateShaderValue();

            LCC3ShaderUniform light0DiffuseColorUniform = _tankShader.UniformNamed("DirLight0DiffuseColor");
            LCC3Vector light0DiffuseColor = new LCC3Vector(1.0f, 2.0f, 2.0f);
            light0DiffuseColorUniform.SetValue(light0DiffuseColor);
            light0DiffuseColorUniform.UpdateShaderValue();

            LCC3ShaderUniform light0SpecularColorUniform = _tankShader.UniformNamed("DirLight0SpecularColor");
            LCC3Vector light0SpecularColor = new LCC3Vector(1.0f, 0.0f, 0.0f);
            light0SpecularColorUniform.SetValue(light0SpecularColor);
            light0DiffuseColorUniform.UpdateShaderValue();
        }
예제 #6
0
 public static void RemoveProgram(LCC3ShaderProgram program)
 {
     LCC3ShaderProgram.RemoveProgramNamed(program.Name);
 }
예제 #7
0
        public static void AddProgram(LCC3ShaderProgram program)
        {
            if (program == null)
                return;

            Debug.Assert(LCC3ShaderProgram.GetProgramNamed(program.Name) !=null,
                         String.Format(@"Already contains a program named {0}
                            Remove it first before adding another", program.Name));

            LCC3ShaderProgram._programsByName.Add(program.Name, program);
        }
 public LCC3ShaderProgramContext(LCC3ShaderProgram program)
 {
     _uniforms = new List<LCC3ShaderUniform>();
     _uniformsByName = new Dictionary<string, LCC3ShaderUniform>();
     this.Program = program;
 }
예제 #9
0
 public static LCC3ShaderAttribute VariableInProgram(LCC3ShaderProgram program, LCC3VertexAttrIndex attrIndex)
 {
     return new LCC3ShaderAttribute(program, attrIndex);
 }