Пример #1
0
 public void ExecutePass(DeviceContext context, RenderTargetSet target, RenderTargetSet source)
 {
     using (new GpuProfilePoint(context, "ResolveMotionVectors"))
     {
         source.BindDepthAsSRV(context, 0);
         target.BindAsRenderTarget(context);
         PostEffectHelper.RenderFullscreenTriangle(context, "ResolveMotionVectors");
         RenderTargetSet.BindNull(context);
         ContextHelper.ClearSRVs(context);
     }
 }
Пример #2
0
 public static void LinearizeDepth(DeviceContext context, RenderTargetSet target, RenderTargetSet source)
 {
     using (new GpuProfilePoint(context, "LinearizeDepth"))
     {
         source.BindDepthAsSRV(context, 0);
         target.BindAsRenderTarget(context);
         PostEffectHelper.RenderFullscreenTriangle(context, "LinearizeDepth");
         RenderTargetSet.BindNull(context);
         ContextHelper.ClearSRVs(context);
     }
 }
Пример #3
0
 public void ExecutePass(DeviceContext context, RenderTargetSet target, RenderTargetSet source)
 {
     using (new GpuProfilePoint(context, "ResolveMotionVectors"))
     {
         source.BindDepthAsSRV(context, 0);
         target.BindAsRenderTarget(context);
         PostEffectHelper.RenderFullscreenTriangle(context, "ResolveMotionVectors");
         RenderTargetSet.BindNull(context);
         ContextHelper.ClearSRVs(context);
     }
 }
Пример #4
0
        public void ExecutePass(DeviceContext context, RenderTargetSet target, RenderTargetSet source, RenderTargetSet depthSource)
        {
            using (new GpuProfilePoint(context, "Bokeh DoF"))
            {
                RenderTargetSet halfResColorCoC = RenderTargetManager.RequestRenderTargetFromPool(m_HalfResDescriptor);
                RenderTargetSet bokehAccumulate = RenderTargetManager.RequestRenderTargetFromPool(m_HalfHeightDescriptor);

                using (new GpuProfilePoint(context, "Downsample"))
                {
                    source.BindSRV(context, 0);
                    depthSource.BindDepthAsSRV(context, 1);
                    halfResColorCoC.BindAsRenderTarget(context);
                    PostEffectHelper.RenderFullscreenTriangle(context, "DownsampleColorCoC");
                    ContextHelper.ClearSRVs(context);
                }

                using (new GpuProfilePoint(context, "Sprites"))
                {
                    bokehAccumulate.Clear(context, new Color4(0.0f, 0.0f, 0.0f, 0.0f));
                    bokehAccumulate.BindAsRenderTarget(context, false);
                    halfResColorCoC.BindSRV(context, 0);
                    context.PixelShader.SetShaderResource(m_BokehSpriteTextureSRV, 4);

                    context.VertexShader.Set(ShaderManager.GetVertexShader("VertexFullScreenDofGrid"));
                    context.PixelShader.Set(ShaderManager.GetPixelShader("BokehSprite"));

                    ContextHelper.SetBlendState(context, ContextHelper.BlendType.Additive);
                    PostEffectHelper.RenderFullscreenGrid(context, m_NumQuads);
                    ContextHelper.SetBlendState(context, ContextHelper.BlendType.None);
                    ContextHelper.ClearSRVs(context);
                }

                using (new GpuProfilePoint(context, "ResolveBokeh"))
                {
                    target.BindAsRenderTarget(context);
                    source.BindSRV(context, 0);
                    bokehAccumulate.BindSRV(context, 2);
                    halfResColorCoC.BindSRV(context, 3);
                    PostEffectHelper.RenderFullscreenTriangle(context, m_DebugBokeh ? "ResolveBokehDebug" : "ResolveBokeh");
                    ContextHelper.ClearSRVs(context);
                }

                RenderTargetManager.ReleaseRenderTargetToPool(halfResColorCoC);
                RenderTargetManager.ReleaseRenderTargetToPool(bokehAccumulate);

                RenderTargetSet.BindNull(context);
            }
        }
Пример #5
0
        public void ExecutePass(DeviceContext context, RenderTargetSet target, RenderTargetSet source, RenderTargetSet depthSource)
        {
            using (new GpuProfilePoint(context, "Bokeh DoF"))
            {
                RenderTargetSet halfResColorCoC = RenderTargetManager.RequestRenderTargetFromPool(m_HalfResDescriptor);
                RenderTargetSet bokehAccumulate = RenderTargetManager.RequestRenderTargetFromPool(m_HalfHeightDescriptor);

                using (new GpuProfilePoint(context, "Downsample"))
                {
                    source.BindSRV(context, 0);
                    depthSource.BindDepthAsSRV(context, 1);
                    halfResColorCoC.BindAsRenderTarget(context);
                    PostEffectHelper.RenderFullscreenTriangle(context, "DownsampleColorCoC");
                    ContextHelper.ClearSRVs(context);
                }

                using (new GpuProfilePoint(context, "Sprites"))
                {
                    bokehAccumulate.Clear(context, new Color4(0.0f, 0.0f, 0.0f, 0.0f));
                    bokehAccumulate.BindAsRenderTarget(context, false);
                    halfResColorCoC.BindSRV(context, 0);
                    context.PixelShader.SetShaderResource(m_BokehSpriteTextureSRV, 4);

                    context.VertexShader.Set(ShaderManager.GetVertexShader("VertexFullScreenDofGrid"));
                    context.PixelShader.Set(ShaderManager.GetPixelShader("BokehSprite"));

                    ContextHelper.SetBlendState(context, ContextHelper.BlendType.Additive);
                    PostEffectHelper.RenderFullscreenGrid(context, m_NumQuads);
                    ContextHelper.SetBlendState(context, ContextHelper.BlendType.None);
                    ContextHelper.ClearSRVs(context);
                }

                using (new GpuProfilePoint(context, "ResolveBokeh"))
                {
                    target.BindAsRenderTarget(context);
                    source.BindSRV(context, 0);
                    bokehAccumulate.BindSRV(context, 2);
                    halfResColorCoC.BindSRV(context, 3);
                    PostEffectHelper.RenderFullscreenTriangle(context, m_DebugBokeh ? "ResolveBokehDebug" : "ResolveBokeh");
                    ContextHelper.ClearSRVs(context);
                }

                RenderTargetManager.ReleaseRenderTargetToPool(halfResColorCoC);
                RenderTargetManager.ReleaseRenderTargetToPool(bokehAccumulate);

                RenderTargetSet.BindNull(context);
            }
        }
Пример #6
0
        public RenderTargetSet RenderShadows(DeviceContext context, SimpleSceneWrapper simpleSceneWrapper)
        {
            RenderTargetSet.RenderTargetDescriptor evsmDescriptor =
                new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R32G32B32A32_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = 1024,
                m_Width       = 1024
            };

            RenderTargetSet EVSMTexture = m_EVSMTexture == null?RenderTargetManager.RequestRenderTargetFromPool(evsmDescriptor) : m_EVSMTexture;

            {
                RenderTargetSet.RenderTargetDescriptor shadowMapDescriptor =
                    new RenderTargetSet.RenderTargetDescriptor()
                {
                    m_Format      = Format.Unknown,
                    m_HasDepth    = true,
                    m_NumSurfaces = 0,
                    m_Height      = 2048,
                    m_Width       = 2048
                };

                RenderTargetSet shadowBuffer = RenderTargetManager.RequestRenderTargetFromPool(shadowMapDescriptor);

                using (new GpuProfilePoint(context, "Shadowmap"))
                {
                    // set the shaders
                    context.VertexShader.Set(ShaderManager.GetVertexShader("VertexShadow"));
                    context.PixelShader.Set(null);

                    shadowBuffer.Clear(context, new Color4(), true);
                    shadowBuffer.BindAsRenderTarget(context, true);

                    ContextHelper.SetDepthStencilState(context, ContextHelper.DepthConfigurationType.DepthWriteCompare);

                    // render triangles
                    simpleSceneWrapper.RenderNoMaterials(context);

                    RenderTargetSet.BindNull(context);
                }

                using (new GpuProfilePoint(context, "EVSM Resolve"))
                {
                    shadowBuffer.BindDepthAsSRV(context, 0);
                    EVSMTexture.BindAsRenderTarget(context);
                    PostEffectHelper.RenderFullscreenTriangle(context, "ReconstructEVSM");
                    RenderTargetSet.BindNull(context);
                    ContextHelper.ClearSRVs(context);
                }

                RenderTargetSet EVSMTextureTemp = RenderTargetManager.RequestRenderTargetFromPool(evsmDescriptor);

                using (new GpuProfilePoint(context, "EVSM Blur"))
                {
                    EVSMTexture.BindSRV(context, 1);
                    EVSMTextureTemp.BindAsRenderTarget(context);
                    PostEffectHelper.RenderFullscreenTriangle(context, "BlurEVSMHorizontal");
                    RenderTargetSet.BindNull(context);
                    ContextHelper.ClearSRVs(context);

                    EVSMTextureTemp.BindSRV(context, 1);
                    EVSMTexture.BindAsRenderTarget(context);
                    PostEffectHelper.RenderFullscreenTriangle(context, "BlurEVSMVertical");
                    RenderTargetSet.BindNull(context);
                    ContextHelper.ClearSRVs(context);
                }

                RenderTargetManager.ReleaseRenderTargetToPool(shadowBuffer);
                RenderTargetManager.ReleaseRenderTargetToPool(EVSMTextureTemp);
            }

            m_EVSMTexture = EVSMTexture;
            return(EVSMTexture);
        }