コード例 #1
0
ファイル: GenericMaterial.cs プロジェクト: Hengle/SFGraphics
        public void SetShaderUniforms(Shader shader)
        {
            foreach (var uniform in intUniformsByName)
            {
                shader.SetInt(uniform.Key, uniform.Value);
            }

            foreach (var uniform in floatUniformsByName)
            {
                shader.SetFloat(uniform.Key, uniform.Value);
            }

            foreach (var uniform in vec2UniformsByName)
            {
                shader.SetVector2(uniform.Key, uniform.Value);
            }

            foreach (var uniform in vec3UniformsByName)
            {
                shader.SetVector3(uniform.Key, uniform.Value);
            }

            foreach (var uniform in vec4UniformsByName)
            {
                shader.SetVector4(uniform.Key, uniform.Value);
            }

            foreach (var uniform in mat4UniformsByName)
            {
                Matrix4 value = uniform.Value;
                shader.SetMatrix4x4(uniform.Key, ref value);
            }
        }
コード例 #2
0
        private static void DrawPolygonUv(NUD.Polygon p, int windowWidth, int windowHeight)
        {
            Shader shader = OpenTKSharedResources.shaders["UV"];

            shader.UseProgram();
            shader.EnableVertexAttributes();
            uvPositionVbo.Bind();

            // Draw over everything
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
            GL.Clear(ClearBufferMask.DepthBufferBit);

            // Scale to 0 to 1 UV space and flip vertically.
            Matrix4 matrix = Matrix4.CreateOrthographicOffCenter(0, 1, 1, 0, -1, 1);

            shader.SetMatrix4x4("mvpMatrix", ref matrix);

            SetVertexAttributes(shader);

            // Draw the uvs.
            GL.LineWidth(1.5f);
            GL.Enable(EnableCap.LineSmooth);

            uvElementsIbo.Bind();
            GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);

            shader.DisableVertexAttributes();
        }
コード例 #3
0
        public void Draw(Matrix4 mvpMatrix)
        {
            Shader shader = OpenTKSharedResources.shaders["SolidColor3D"];

            if (!shader.ProgramCreatedSuccessfully)
            {
                return;
            }

            // Set up.
            shader.UseProgram();
            shader.EnableVertexAttributes();
            positionBuffer.Bind();

            // Set shader values.
            Matrix4 matrix = mvpMatrix;

            shader.SetMatrix4x4("mvpMatrix", ref matrix);

            // Draw.
            int rectangularPrismVertCount = 24;

            GL.DrawArrays(PrimitiveType.TriangleFan, 0, rectangularPrismVertCount);

            shader.DisableVertexAttributes();
        }
コード例 #4
0
        private static void SetShaderUniforms(Matrix4 mvpMatrix, float scaleX, float scaleY, float scaleZ, float centerX, float centerY, float centerZ, Shader shader)
        {
            shader.SetVector3("center", centerX, centerY, centerZ);
            shader.SetVector3("scale", scaleX, scaleY, scaleZ);
            shader.SetVector4("color", new Vector4(1, 0, 1, 1));
            Matrix4 matrix = mvpMatrix;

            shader.SetMatrix4x4("mvpMatrix", ref matrix);
        }