Example #1
0
        protected override void CreateRenderPath()
        {
            this.Add(new ShadowPass());

            geometryPass = new FrameGraphPass(SubmitQueue.EarlyGraphics)
            {
                new AttachmentInfo("albedo", SizeHint.Full, VkFormat.R8G8B8A8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),
                new AttachmentInfo("normal", SizeHint.Full, VkFormat.R8G8B8A8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),
                new AttachmentInfo(depthTexture.format),

                new SceneSubpass("gbuffer")
                {
                    Set1 = clusterSet1
                }
            };

            geometryPass.renderPassCreator = OnCreateRenderPass;

            this.Add(geometryPass);

            translucentClustering = this.CreateClusteringPass();

            this.Add(translucentClustering);

            if (enableSSAO)
            {
                ssaoPass = new FrameGraphPass
                {
                    new AttachmentInfo("ssao", SizeHint.Full, VkFormat.R8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),

                    new SSAOSubpass()
                };

                this.Add(ssaoPass);

                ssaoBlur = new FrameGraphPass
                {
                    new AttachmentInfo("ssao_blur", SizeHint.Full, VkFormat.R8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),

                    new SSAOBlurSubpass()
                };

                this.Add(ssaoBlur);
            }

            lightCull = new ComputePass(ComputeLight);
            this.Add(lightCull);

            var specializationInfo = new SpecializationInfo(new VkSpecializationMapEntry(0, 0, sizeof(uint)));

            specializationInfo.Write(0, enableSSAO ? 1 : 0);

            compositePass = new FrameGraphPass
            {
                new AttachmentInfo("color", SizeHint.Full, VkFormat.R8G8B8A8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),
                new AttachmentInfo(depthTexture.format)
                {
                    storeOp = VkAttachmentStoreOp.Store
                },

                new FullScreenSubpass("shaders/glsl/cluster_deferred.frag", specializationInfo)
                {
Example #2
0
        public ForwardHdrRenderer()
        {
            Add(new ShadowPass());

            var fgPass = new FrameGraphPass
            {
                new AttachmentInfo("color", SizeHint.Full, VkFormat.R16G16B16A16SFloat, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled | VkImageUsageFlags.InputAttachment)
                {
                    finalLayout = VkImageLayout.ShaderReadOnlyOptimal
                },

                new AttachmentInfo(Graphics.DepthFormat),

                new SceneSubpass
                {
                    DisableDepthStencil = false
                }
            };


            Add(fgPass);


            var specializationInfo = new SpecializationInfo(new VkSpecializationMapEntry(0, 0, sizeof(uint)));

            specializationInfo.Write(0, 1);

            var onScreenPass = new FrameGraphPass
            {
                new AttachmentInfo(Graphics.Swapchain.ColorFormat),

                new FullScreenSubpass("shaders/post/fullscreen.frag")
                {
                    onBindResource = (rs) =>
                    {
                        rs.SetResourceSet(0, fgPass.RenderTarget[0]);
                    }
                },

                new FullScreenSubpass("shaders/post/bloom.frag")
                {
                    AddtiveMode = true,

                    onBindResource = (rs) =>
                    {
                        rs.SetResourceSet(0, fgPass.RenderTarget[0]);
                    }
                },


                new FullScreenSubpass("shaders/post/bloom.frag", specializationInfo)
                {
                    AddtiveMode = true,

                    onBindResource = (rs) =>
                    {
                        rs.SetResourceSet(0, fgPass.RenderTarget[0]);
                    }
                }
            };


            Add(onScreenPass);
        }