protected override void InitializationProcess()
        {
            MainFramebuffer = CreateWindowFramebuffer(8, PixelInformation.RGBA_HDR, true);
            _postBuffer     = CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false);
            Framebuffers.Add(_postBuffer);

            _bloom = new BloomEffect(true, true)
            {
                Radius    = 20,
                AmountMap = new Texture(new System.Drawing.Bitmap("bloom_amountMap.png"))
            };
            PostProcessEffects.Add(_bloom);

            _vittage = new STPostProcessEffect(Program.portal.DrawNodes.Find(a => a.Variables.ContainsKey("_ViewportSize")))
            {
                Arguments =
                {
                    { "CheckSize",    10f },
                    { "Strength",    .25f },
                    { "TargetSize",    5f },
                    { "Move",       3.33f }
                }
            };
            PostProcessEffects.Add(_vittage);
        }
Esempio n. 2
0
 protected override void OnUnregisterImage(VKImage image)
 {
     Framebuffers[image].Dispose();
     Framebuffers.Remove(image);
     ComputeCommandBuffers[image].Dispose();
     ComputeCommandBuffers.Remove(image);
 }
        private void SetupFramebuffers(List <FrameBufferRef> mainBuffers)
        {
            if (_frameBuffer != null)
            {
                _platform.DisposeFrameBuffer(_frameBuffer);
                _frameBuffer = null;
            }

            var ssao = ClientSettings.SSAOQuality > 0;

            if (!ssao || !_enabled)
            {
                return;
            }

            var fbPrimary = mainBuffers[(int)EnumFrameBuffer.Primary];

            var fbWidth  = (int)(_platform.window.Width * ClientSettings.SSAA);
            var fbHeight = (int)(_platform.window.Height * ClientSettings.SSAA);

            if (fbWidth == 0 || fbHeight == 0)
            {
                return;
            }

            var fb = new FrameBufferRef
            {
                FboId           = GL.GenFramebuffer(),
                Width           = fbWidth,
                Height          = fbHeight,
                ColorTextureIds = ArrayUtil.CreateFilled(2, _ => GL.GenTexture())
            };

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, fb.FboId);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment,
                                    TextureTarget.Texture2D, fbPrimary.DepthTextureId, 0);
            fb.SetupColorTexture(0);
            fb.SetupColorTexture(1);

            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment2,
                                    TextureTarget.Texture2D, fbPrimary.ColorTextureIds[2], 0);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment3,
                                    TextureTarget.Texture2D, fbPrimary.ColorTextureIds[3], 0);
            GL.DrawBuffers(4, new []
            {
                DrawBuffersEnum.ColorAttachment0, DrawBuffersEnum.ColorAttachment1,
                DrawBuffersEnum.ColorAttachment2, DrawBuffersEnum.ColorAttachment3
            });

            Framebuffers.CheckStatus();
            _frameBuffer = fb;

            _screenQuad = _platform.GetScreenQuad();
        }
        public void Initialization()
        {
            InitializationProcess();

            InitizePostProcessing();
            if (MainFramebuffer != null)
            {
                Framebuffers.Add(MainFramebuffer);
                MainFramebuffer.Name = GetType().Name + ".MainFramebuffer";
            }
            DefaultShader ??= SMRenderer.DefaultMaterialShader;
        }
Esempio n. 5
0
 protected override void OnRegisterImage(VKImage image)
 {
     Framebuffers.Add(image, RenderPass.RenderPass.CreateFramebuffer(new FramebufferCreateInfo(
                                                                         attachments: new[] { image.ImageView },
                                                                         width: image.Extent.Width,
                                                                         height: image.Extent.Height
                                                                         )));
     ComputeCommandBuffers.Add(
         image,
         Graphics.ComputeQueueFamily.CreateCommandBuffers(
             CommandBufferLevel.Primary,
             1
             )[0]
         );
 }
        public void SetupFramebuffers(List <FrameBufferRef> mainBuffers)
        {
            _mod.Mod.Logger.Event("Recreating framebuffers");

            for (var i = 0; i < _framebuffers.Length; i++)
            {
                if (_framebuffers[i] == null)
                {
                    continue;
                }

                _platform.DisposeFrameBuffer(_framebuffers[i]);
                _framebuffers[i] = null;
            }

            // create new framebuffer
            _fbWidth  = (int)(_platform.window.Width * ClientSettings.SSAA);
            _fbHeight = (int)(_platform.window.Height * ClientSettings.SSAA);
            if (_fbWidth == 0 || _fbHeight == 0)
            {
                return;
            }

            var framebuffer = new FrameBufferRef
            {
                FboId = GL.GenFramebuffer(), Width = _fbWidth, Height = _fbHeight, DepthTextureId = GL.GenTexture()
            };

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer.FboId);
            framebuffer.SetupDepthTexture();

            // create our normal and position textures
            framebuffer.ColorTextureIds = ArrayUtil.CreateFilled(_refractionsEnabled ? 4 : 3, _ => GL.GenTexture());

            // bind and setup textures
            framebuffer.SetupVertexTexture(0);
            framebuffer.SetupVertexTexture(1);
            framebuffer.SetupColorTexture(2);
            if (_refractionsEnabled)
            {
                framebuffer.SetupVertexTexture(3);
            }

            if (_refractionsEnabled)
            {
                GL.DrawBuffers(4,
                               new[]
                {
                    DrawBuffersEnum.ColorAttachment0, DrawBuffersEnum.ColorAttachment1, DrawBuffersEnum.ColorAttachment2,
                    DrawBuffersEnum.ColorAttachment3
                });
            }
            else
            {
                GL.DrawBuffers(3,
                               new[]
                {
                    DrawBuffersEnum.ColorAttachment0, DrawBuffersEnum.ColorAttachment1,
                    DrawBuffersEnum.ColorAttachment2
                });
            }

            Framebuffers.CheckStatus();
            _framebuffers[(int)EnumSSRFB.SSR] = framebuffer;

            // setup output framebuffer
            framebuffer = new FrameBufferRef
            {
                FboId = GL.GenFramebuffer(), Width = _fbWidth, Height = _fbHeight
            };
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer.FboId);
            framebuffer.ColorTextureIds = new[] { GL.GenTexture() };

            framebuffer.SetupColorTexture(0);

            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
            Framebuffers.CheckStatus();
            _framebuffers[(int)EnumSSRFB.Out] = framebuffer;

            if (_causticsEnabled)
            {
                framebuffer = new FrameBufferRef
                {
                    FboId = GL.GenFramebuffer(), Width = _fbWidth, Height = _fbHeight
                };
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer.FboId);
                framebuffer.ColorTextureIds = new[] { GL.GenTexture() };

                framebuffer.SetupSingleColorTexture(0);

                GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
                Framebuffers.CheckStatus();
                _framebuffers[(int)EnumSSRFB.Caustics] = framebuffer;
            }

            _screenQuad = _platform.GetScreenQuad();
        }