Example #1
0
 // Конструктор
 protected SkyboxShader() : base()
 {
     if (vertexAttrib == null)
     {
         vertexAttrib = new VertexAttribute("inPosition");
         attribs.Add(vertexAttrib);
     }
     if (texCoordAttrib == null)
     {
         texCoordAttrib = new VertexAttribute("inTexCoord");
         attribs.Add(texCoordAttrib);
     }
     if (textureUniform == null)
     {
         textureUniform = new TextureUniform("texture");
         uniforms.Add(textureUniform);
     }
     if (diffuseColor == null)
     {
         diffuseColor = new ColorUniform("diffuseColor");
         uniforms.Add(diffuseColor);
     }
     if (textureMatrix == null)
     {
         textureMatrix = new MatrixUniform("textureMatrix");
         uniforms.Add(textureMatrix);
     }
 }
Example #2
0
        protected override void OnLinked()
        {
            this.World      = new MatrixUniform(this, "u_world");
            this.View       = new MatrixUniform(this, "u_view");
            this.Projection = new MatrixUniform(this, "u_projection");

            this.Vertex   = new Attribute(this, "a_vertex");
            this.TexCoord = new Attribute(this, "a_texcoord");

            this.BaseTexture = new TextureUniform(this, "t_base");
        }
Example #3
0
 /// <summary>
 /// Конструктор программы
 /// </summary>
 protected ShaderBase()
 {
     if (uniforms == null)
     {
         uniforms         = new List <Uniform>();
         projectionMatrix = new MatrixUniform("projectionMatrix");
         cameraMatrix     = new MatrixUniform("cameraMatrix");
         entityMatrix     = new MatrixUniform("entityMatrix");
         uniforms.AddRange(new MatrixUniform[] {
             cameraMatrix, entityMatrix, projectionMatrix
         });
     }
     if (attribs == null)
     {
         attribs = new List <VertexAttribute>();
     }
 }
Example #4
0
        public TerrainShader(IOpenGL33 gl)
        {
            vertexShader = new VertexShader(gl, GetEmbeddedResourceAsString("VertexShader.vs"));
            fragmentShader = new FragmentShader(gl, GetEmbeddedResourceAsString("FragmentShader.fs"));
            var p = new ModGL.ObjectModel.Shaders.Program(gl, vertexShader, fragmentShader);

            p.BindVertexAttributeLocations(PositionNormalTexCoord.Descriptor);
            // Bind output fragment to the specified nme
            gl.BindFragDataLocation(p.Handle, 0, "Color");
            // Compile program and shaders
            p.Compile();
            program = p;
            // Get the uniforms used by the shader program.
            diffuseUniform = p.GetUniform<Vector4fUniform, Vector4f>("DiffuseColor");
            modelViewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ModelViewProjection");
            viewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ViewProjection");
            textureUnitUniform = p.GetUniform<IntUniform, int>("Texture");
        }
Example #5
0
 // Конструктор
 protected MeshShader() : base()
 {
     if (vertexAttrib == null)
     {
         vertexAttrib = new VertexAttribute("inPosition");
         attribs.Add(vertexAttrib);
     }
     if (normalAttrib == null)
     {
         normalAttrib = new VertexAttribute("inNormal");
         attribs.Add(normalAttrib);
     }
     if (texCoordAttrib == null)
     {
         texCoordAttrib = new VertexAttribute("inTexCoord");
         attribs.Add(texCoordAttrib);
     }
     if (textureUniform == null)
     {
         textureUniform = new TextureUniform("texture");
         uniforms.Add(textureUniform);
     }
     if (diffuseColor == null)
     {
         diffuseColor = new ColorUniform("diffuseColor");
         uniforms.Add(diffuseColor);
     }
     if (alphaPass == null)
     {
         alphaPass = new BoolUniform("discardPass");
         uniforms.Add(alphaPass);
     }
     if (lightMultiplier == null)
     {
         lightMultiplier = new FloatUniform("lightMult");
         uniforms.Add(lightMultiplier);
     }
     if (textureMatrix == null)
     {
         textureMatrix = new MatrixUniform("textureMatrix");
         uniforms.Add(textureMatrix);
     }
 }
Example #6
0
        public override void SetupMaterial()
        {
            MakeCurrent();
            projection = Shader.GetUniformType <MatrixUniform, Matrix>("projection_mat");
            modelview  = Shader.GetUniformType <MatrixUniform, Matrix>("modelview_mat");
            texture    = Shader.GetUniformType <MatrixUniform, Matrix>("texture_mat");
            normal     = Shader.GetUniformType <MatrixUniform, Matrix>("normal_mat");

            pos_attrib    = Shader.GetAttributeLocation("in_position");
            norm_attrib   = Shader.GetAttributeLocation("in_normal");
            color0_attrib = Shader.GetAttributeLocation("in_color0");
            color1_attrib = Shader.GetAttributeLocation("in_color1");
            color2_attrib = Shader.GetAttributeLocation("in_color2");
            color3_attrib = Shader.GetAttributeLocation("in_color3");

            texcoord0_attrib = Shader.GetAttributeLocation("in_texcoord0");
            texcoord1_attrib = Shader.GetAttributeLocation("in_texcoord1");
            texcoord2_attrib = Shader.GetAttributeLocation("in_texcoord2");
            texcoord3_attrib = Shader.GetAttributeLocation("in_texcoord3");
        }
Example #7
0
 public CubeShader(IOpenGL30 gl)
 {
     // Create the vertex shader
     vertexShader = new VertexShader(gl, GetEmbeddedResourceAsString("cube.vs"));
     // Create the fragmet shader
     fragmentShader = new FragmentShader(gl, GetEmbeddedResourceAsString("cube.fs"));
     // Create the program for both shaders
     var p = new ModGL.ObjectModel.Shaders.Program(gl, vertexShader, fragmentShader);
     // Tell the shader what field names to use (taken from the vertex Descriptor)
     p.BindVertexAttributeLocations(PositionNormalTexCoord.Descriptor);
     // Bind output fragment to the specified nme
     gl.BindFragDataLocation(p.Handle, 0, "Color");
     // Compile program and shaders
     p.Compile();
     program = p;
     // Get the uniforms used by the shader program.
     modelViewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ModelViewProjection");
     viewProjection = p.GetUniform<MatrixUniform, Matrix4f>("ViewProjection");
     diffuseUniform = p.GetUniform<Vector4fUniform, Vector4f>("DiffuseColor");
 }
Example #8
0
        public override void SetupMaterial()
        {
            MakeCurrent();
            projection = Shader.GetUniformType<MatrixUniform, Matrix>("projection_mat");
            modelview = Shader.GetUniformType<MatrixUniform, Matrix>("modelview_mat");
            texture = Shader.GetUniformType<MatrixUniform, Matrix>("texture_mat");
            normal = Shader.GetUniformType<MatrixUniform, Matrix>("normal_mat");

            pos_attrib = Shader.GetAttributeLocation("in_position");
            norm_attrib = Shader.GetAttributeLocation("in_normal");
            color0_attrib = Shader.GetAttributeLocation("in_color0");
            color1_attrib = Shader.GetAttributeLocation("in_color1");
            color2_attrib = Shader.GetAttributeLocation("in_color2");
            color3_attrib = Shader.GetAttributeLocation("in_color3");

            texcoord0_attrib = Shader.GetAttributeLocation("in_texcoord0");
            texcoord1_attrib = Shader.GetAttributeLocation("in_texcoord1");
            texcoord2_attrib = Shader.GetAttributeLocation("in_texcoord2");
            texcoord3_attrib = Shader.GetAttributeLocation("in_texcoord3");
        }