コード例 #1
0
        protected override void setFramebuffers()
        {
            base.genFramebuffers(3);

            base.bindFramebuffer(1);
            base.attachTextureToFramebuffer(FramebufferAttachment.ColorAttachment0, verticalBlurTexture.GetTextureDescriptor());
            base.bindFramebuffer(2);
            base.attachTextureToFramebuffer(FramebufferAttachment.ColorAttachment0, horizontalBlurTexture.GetTextureDescriptor());
            base.bindFramebuffer(3);
            base.attachTextureToFramebuffer(FramebufferAttachment.ColorAttachment0, bloomResultTexture.GetTextureDescriptor());
            base.unbindFramebuffer();
        }
コード例 #2
0
        protected override void setFramebuffers()
        {
            genFramebuffers(3);

            bindFramebuffer(1);
            attachTextureToFramebuffer(FramebufferAttachment.ColorAttachment0, VerticalBlurTexture.GetTextureDescriptor());
            bindFramebuffer(2);
            attachTextureToFramebuffer(FramebufferAttachment.ColorAttachment0, HorizontalBlurTexture.GetTextureDescriptor());
            bindFramebuffer(3);
            attachTextureToFramebuffer(FramebufferAttachment.ColorAttachment0, DepthOfFieldResultTexture.GetTextureDescriptor());
            unbindFramebuffer();
        }
コード例 #3
0
        public static ITexture CopyTexture(ITexture src)
        {
            ITexture dst = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(src.GetTextureParameters());

            var renderTarget = GL.GenFramebuffer();

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, renderTarget);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, src.GetTextureParameters().TexTarget, dst.GetTextureDescriptor(), 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);

            //GL.Disable(EnableCap.DepthTest);
            GL.Viewport(0, 0, src.GetTextureRezolution().X, src.GetTextureRezolution().Y);
            // start copy texture to render target
            copyShader.startProgram();
            src.BindTexture(TextureUnit.Texture0);
            copyShader.SetUniformValues(0);
            var quadBuffer = ScreenQuad.GetScreenQuadBuffer();

            quadBuffer.RenderVAO(PrimitiveType.Triangles);
            copyShader.stopProgram();
            GL.Enable(EnableCap.DepthTest);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            GL.DeleteFramebuffer(renderTarget);

            return(dst);
        }
コード例 #4
0
        private void InitFramebuffer(Int32 WidthRezolution, Int32 HeightRezolution)
        {
            var ColorTextureParams        = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Rgb, WidthRezolution, HeightRezolution, PixelFormat.Rgb, PixelType.UnsignedByte, TextureWrapMode.Repeat);
            var DepthStencilTextureParams = new TextureParameters(TextureTarget.Texture2D, TextureMagFilter.Nearest, TextureMinFilter.Nearest, 0, PixelInternalFormat.Depth24Stencil8, WidthRezolution, HeightRezolution, PixelFormat.DepthComponent, PixelType.Float, TextureWrapMode.Repeat);

            ColorTexture        = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(ColorTextureParams);
            DepthStencilTexture = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(DepthStencilTextureParams);

            FramebufferDescriptor = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, FramebufferDescriptor);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, ColorTexture.GetTextureDescriptor(), 0);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthStencilAttachment, TextureTarget.Texture2D, DepthStencilTexture.GetTextureDescriptor(), 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
            GL.ReadBuffer(ReadBufferMode.None);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
コード例 #5
0
 private void PrepareRenderTarget()
 {
     GL.BindFramebuffer(FramebufferTarget.Framebuffer, m_framebufferHandler);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, m_shadowMapTexture.GetTextureDescriptor(), 0);
     GL.DrawBuffer(DrawBufferMode.None);
     GL.ReadBuffer(ReadBufferMode.None);
     GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
 }