Exemple #1
0
        protected override void OnLoad()
        {
            texture = Texture.Empty(1, 1, PixelInternalFormat.Rgba);

            renderTarget = new RenderTarget();
            // ReSharper disable once ConvertToUsingDeclaration
            using (var target = renderTarget.Bind())
            {
                target.SetColorAttachments(texture);
            }

            shapeShaderProgram = ShaderProgram.FromShaders(
                ShaderFactory.Vertex.FromFile("geometry.vs"), ShaderFactory.Fragment.FromFile("geometry.fs"));

            meshBuilder = new IndexedTrianglesMeshBuilder <ColorVertexData>();

            var shapeDrawer =
                new ShapeDrawer3 <ColorVertexData, Color>(meshBuilder, (xyz, color) => new ColorVertexData(xyz, color));

            shapeDrawer.DrawCube(Vector3.Zero, 1f, Color.Aqua);

            var shapeRenderable = meshBuilder.ToRenderable();

            shapeRenderer = Renderer.From(shapeRenderable, shapeShaderProgram, viewMatrix, projectionMatrix);

            viewMatrix.Value = Matrix4.LookAt(new Vector3(0, 1, -2), Vector3.Zero, Vector3.UnitY);

            postProcessShader = ShaderProgram.FromShaders(
                ShaderFactory.Vertex.FromFile("postprocess.vs"), ShaderFactory.Fragment.FromFile("postprocess.fs"));

            postProcessor = PostProcessor.From(postProcessShader,
                                               new TextureUniform("inTexture", TextureUnit.Texture0, texture), pixelSizeUniform);
        }
Exemple #2
0
        public static IPipeline <TState> PostProcess(IRendererShader shaderProgram, out IDisposable disposable,
                                                     params IRenderSetting[] renderSettings)
        {
            var postProcessor = PostProcessor.From(renderSettings);

            shaderProgram.UseOnRenderer(postProcessor);
            disposable = postProcessor;
            return(new PostProcess <TState>(postProcessor));
        }