Beispiel #1
0
        private void ChangeScreenSize()
        {
            Disposer.Dispose(ref _gbuffer);

            _gbuffer = new Framebuffer(_screenSize);
            var albedoTexture   = _gbuffer.AddColorTexture(FramebufferAttachment.ColorAttachment0, PixelInternalFormat.Rgba8, PixelFormat.Rgba);    //albedo - xyz, spec intensity - w
            var emissionTexture = _gbuffer.AddColorTexture(FramebufferAttachment.ColorAttachment1, PixelInternalFormat.Rgb8, PixelFormat.Rgb);      //emission - xyz, spec power - w
            var positionTexture = _gbuffer.AddColorTexture(FramebufferAttachment.ColorAttachment2, PixelInternalFormat.Rgb16f, PixelFormat.Rgba);   //view position
            var normalTexture   = _gbuffer.AddColorTexture(FramebufferAttachment.ColorAttachment3, PixelInternalFormat.Rgba16f, PixelFormat.Rgba);  //normal
            var dataTexture     = _gbuffer.AddColorTexture(FramebufferAttachment.ColorAttachment4, PixelInternalFormat.R16ui, PixelFormat.Red);     //material id

            if (_graphics.Backbuffer.DepthAttachment is Renderbuffer)
            {
                _gbuffer.AttachRenderbuffer(FramebufferAttachment.DepthAttachment, (Renderbuffer)_graphics.Backbuffer.DepthAttachment);
            }
            else
            {
                _gbuffer.AttachTexture(FramebufferAttachment.DepthAttachment, (Texture2)_graphics.Backbuffer.DepthAttachment);
            }

            _secondPassMaterial.SetTexture("uniform_AlbedoTexture", albedoTexture);
            _secondPassMaterial.SetTexture("uniform_EmissionTexture", emissionTexture);
            _secondPassMaterial.SetTexture("uniform_NormalTexture", normalTexture);
            _secondPassMaterial.SetTexture("uniform_PositionTexture", positionTexture);
            _secondPassMaterial.SetTexture("uniform_DataTexture", dataTexture);

            //Texture2 depthTexture = null;
            //if (depthTexture != null)
            //    _secondPassMaterial.SetTexture("uniform_DepthTexture", depthTexture);
        }
Beispiel #2
0
        public UIRender(Renderbuffer renderBuffer)
        {
            this._screenSize = renderBuffer.Size;

            _context      = GL.GetCurrent(true);
            _shader       = new UIShader();
            _renderBuffer = renderBuffer;

            _framebuffer = new Framebuffer(_screenSize);

            _framebuffer.AttachRenderbuffer(FramebufferAttachment.ColorAttachment0, renderBuffer);
            _idTexture = _framebuffer.AddColorTexture(Core.FramebufferAttachment.ColorAttachment1, PixelInternalFormat.R32ui, PixelFormat.Red);

            _framebuffer.CheckStatus(true);
        }