示例#1
0
        public PostProcessor()
        {
            mesh = new Mesh("post-process-quad");
            mesh.Unlist();

            mesh.LoadMesh(new Vertex[]
            {
                new Vertex {
                    Position = new Vector3(1.0f, 1.0f, 0.0f), UV = new Vector2(1.0f, 1.0f)
                },
                new Vertex {
                    Position = new Vector3(1.0f, -1.0f, 0.0f), UV = new Vector2(1.0f, 0.0f)
                },
                new Vertex {
                    Position = new Vector3(-1.0f, -1.0f, 0.0f), UV = new Vector2(0.0f, 0.0f)
                },
                new Vertex {
                    Position = new Vector3(-1.0f, 1.0f, 0.0f), UV = new Vector2(0.0f, 1.0f)
                }
            },
                          new uint[]
            {
                0, 1, 3,
                1, 2, 3
            });

            framebuffer = new Framebuffer("post-process-fbo", framebufferSize.X, framebufferSize.Y, new Attachment[]
            {
                new Attachment
                {
                    Draw = false,
                    PixelInternalFormat   = PixelInternalFormat.SrgbAlpha,
                    PixelFormat           = PixelFormat.Rgba,
                    PixelType             = PixelType.Float,
                    FramebufferAttachment = FramebufferAttachment.ColorAttachment0,
                    TextureParamsInt      = new TextureParamInt[]
                    {
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMinFilter, Param = (int)TextureMinFilter.Linear
                        },
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMagFilter, Param = (int)TextureMagFilter.Linear
                        }
                    }
                },
                new Attachment
                {
                    Draw = false,
                    PixelInternalFormat   = PixelInternalFormat.DepthComponent,
                    PixelFormat           = PixelFormat.DepthComponent,
                    PixelType             = PixelType.Float,
                    FramebufferAttachment = FramebufferAttachment.DepthAttachment,
                    TextureParamsInt      = new TextureParamInt[]
                    {
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMinFilter, Param = (int)TextureMinFilter.Nearest
                        },
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMagFilter, Param = (int)TextureMagFilter.Nearest
                        }
                    }
                }
            });
            stageReadFramebuffer = new Framebuffer("stage-post-process-fbo", framebufferSize.X, framebufferSize.Y, new Attachment[]
            {
                new Attachment
                {
                    Draw = false,
                    PixelInternalFormat   = PixelInternalFormat.Rgba,
                    PixelFormat           = PixelFormat.Rgba,
                    PixelType             = PixelType.Float,
                    FramebufferAttachment = FramebufferAttachment.ColorAttachment0,
                    TextureParamsInt      = new TextureParamInt[]
                    {
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMinFilter, Param = (int)TextureMinFilter.Linear
                        },
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMagFilter, Param = (int)TextureMagFilter.Linear
                        }
                    }
                }
            });
            stageDrawFramebuffer = new Framebuffer("stage-post-process-fbo", framebufferSize.X, framebufferSize.Y, new Attachment[]
            {
                new Attachment
                {
                    Draw = false,
                    PixelInternalFormat   = PixelInternalFormat.Rgba,
                    PixelFormat           = PixelFormat.Rgba,
                    PixelType             = PixelType.Float,
                    FramebufferAttachment = FramebufferAttachment.ColorAttachment0,
                    TextureParamsInt      = new TextureParamInt[]
                    {
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMinFilter, Param = (int)TextureMinFilter.Linear
                        },
                        new TextureParamInt {
                            ParamName = TextureParameterName.TextureMagFilter, Param = (int)TextureMagFilter.Linear
                        }
                    }
                }
            });
        }