Ejemplo n.º 1
0
        public void RenderVolumetricFog(DeviceContext context, TextureObject shadowMap, GlobalIlluminationRenderer giRenderer)
        {
            // Not using temporal manager as it was designed for render target sets; TODO
            TextureObject previousFrameAccumulationTexture = m_Phase ? m_LightingTexturePing : m_LightingTexturePong;
            TextureObject currentFrameAccumulationTexture =  m_Phase ? m_LightingTexturePong : m_LightingTexturePing;
            m_Phase = !m_Phase;

            using (new GpuProfilePoint(context, "VolumetricFog"))
            {
#if false
                using (new GpuProfilePoint(context, "DensityEstimation"))
                {
                    context.ComputeShader.SetUnorderedAccessView(m_DensityTexture.m_UnorderedAccessView, 0);
                    ShaderManager.ExecuteComputeForResource(context, m_DensityTexture, "CalculateDensity");
                    ContextHelper.ClearCSContext(context);
                }
#endif

                using (new GpuProfilePoint(context, "LitFogVolume"))
                {
                    context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeR.m_ShaderResourceView, 5);
                    context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeG.m_ShaderResourceView, 6);
                    context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeB.m_ShaderResourceView, 7);

                    context.ComputeShader.SetShaderResource(previousFrameAccumulationTexture.m_ShaderResourceView, 8);

                    context.ComputeShader.SetShaderResource(m_DensityTexture.m_ShaderResourceView, 0);
                    context.ComputeShader.SetShaderResource(shadowMap.m_ShaderResourceView, 1);
                    context.ComputeShader.SetUnorderedAccessView(currentFrameAccumulationTexture.m_UnorderedAccessView, 1);
                    ShaderManager.ExecuteComputeForResource(context, currentFrameAccumulationTexture, "LitFogVolume");
                    ContextHelper.ClearCSContext(context);
                }

                using (new GpuProfilePoint(context, "ComputeScattering"))
                {
                    context.ComputeShader.SetShaderResource(currentFrameAccumulationTexture.m_ShaderResourceView, 0);
                    context.ComputeShader.SetUnorderedAccessView(m_ScatteringTexture.m_UnorderedAccessView, 2);
                    ShaderManager.ExecuteComputeForSize(context, m_VolumeX, m_VolumeY, 1, "ComputeScattering");
                    ContextHelper.ClearCSContext(context);
                }

            }
        }
Ejemplo n.º 2
0
        public void RenderVolumetricFog(DeviceContext context, TextureObject shadowMap, GlobalIlluminationRenderer giRenderer)
        {
            // Not using temporal manager as it was designed for render target sets; TODO
            TextureObject previousFrameAccumulationTexture = m_Phase ? m_LightingTexturePing : m_LightingTexturePong;
            TextureObject currentFrameAccumulationTexture  = m_Phase ? m_LightingTexturePong : m_LightingTexturePing;

            m_Phase = !m_Phase;

            using (new GpuProfilePoint(context, "VolumetricFog"))
            {
#if false
                using (new GpuProfilePoint(context, "DensityEstimation"))
                {
                    context.ComputeShader.SetUnorderedAccessView(m_DensityTexture.m_UnorderedAccessView, 0);
                    ShaderManager.ExecuteComputeForResource(context, m_DensityTexture, "CalculateDensity");
                    ContextHelper.ClearCSContext(context);
                }
#endif

                using (new GpuProfilePoint(context, "LitFogVolume"))
                {
                    context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeR.m_ShaderResourceView, 5);
                    context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeG.m_ShaderResourceView, 6);
                    context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeB.m_ShaderResourceView, 7);

                    context.ComputeShader.SetShaderResource(previousFrameAccumulationTexture.m_ShaderResourceView, 8);

                    context.ComputeShader.SetShaderResource(m_DensityTexture.m_ShaderResourceView, 0);
                    context.ComputeShader.SetShaderResource(shadowMap.m_ShaderResourceView, 1);
                    context.ComputeShader.SetUnorderedAccessView(currentFrameAccumulationTexture.m_UnorderedAccessView, 1);
                    ShaderManager.ExecuteComputeForResource(context, currentFrameAccumulationTexture, "LitFogVolume");
                    ContextHelper.ClearCSContext(context);
                }

                using (new GpuProfilePoint(context, "ComputeScattering"))
                {
                    context.ComputeShader.SetShaderResource(currentFrameAccumulationTexture.m_ShaderResourceView, 0);
                    context.ComputeShader.SetUnorderedAccessView(m_ScatteringTexture.m_UnorderedAccessView, 2);
                    ShaderManager.ExecuteComputeForSize(context, m_VolumeX, m_VolumeY, 1, "ComputeScattering");
                    ContextHelper.ClearCSContext(context);
                }
            }
        }
Ejemplo n.º 3
0
        public void Initialize(Device device, Form form, Panel panel, int resolutionX, int resolutionY)
        {
            m_ResolutionX = resolutionX;
            m_ResolutionY = resolutionY;

            m_FullResDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R16G16B16A16_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_FullResAndDepthDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R16G16B16A16_Float,
                m_HasDepth    = true,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_ResolvedColorDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R8G8B8A8_UNorm,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_LinearDepthDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R32_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };
            m_SSAODescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R8_UNorm,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_SimpleSceneWrapper.Initialize(device, "sponza");

            TemporalSurfaceManager.InitializeRenderTarget("ResolvedColor", m_ResolvedColorDescriptor);

            TemporalSurfaceManager.InitializeRenderTarget("MotionVectors",
                                                          new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R16G16_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            });


            m_PostEffectsConstantBuffer = ShaderManager.CreateConstantBufferInstance("PostEffects", device);
            m_ForwardPassBuffer         = ShaderManager.CreateConstantBufferInstance("ForwardPassBuffer", device);
            m_ViewportConstantBuffer    = ShaderManager.CreateConstantBufferInstance("GlobalViewportBuffer", device);
            m_CurrentViewportBuffer     = ShaderManager.CreateConstantBufferInstance("CurrentViewport", device);

            Vector3 min, max;

            m_SimpleSceneWrapper.GetSceneBounds(out min, out max);

            m_GIRenderer = new GlobalIlluminationRenderer(device, min, max);

            // Init passes
            m_ScatterDOFPass = new ScatterDOFPass();
            m_ScatterDOFPass.Initialize(device, resolutionX, resolutionY);

            m_ResolveHDRPass = new ResolveHDRPass();

            m_ResolveMotionVectorsPass = new ResolveMotionVectorsPass();

            m_ResolveTemporalPass = new ResolveTemporalMotionBasedPass();

            m_FxaaPass = new FxaaPass();

            m_SSAOPass = new SSAOEffectPass(device, resolutionX, resolutionY);

            m_LuminanceCalculations = new LuminanceCalculations(device, resolutionX, resolutionY);

            m_ShadowEVSMGenerator = new ShadowEVSMGenerator();

            m_VolumetricFog = new VolumetricFog();
            m_VolumetricFog.Initialize(device);

            m_StartTime = DateTime.Now;

            m_ViewportCamera.BindToInput(form, panel);

            POISSON_SAMPLES = new float[POISSON_SAMPLE_NUM * 2]
            {
                0.655897408497f, 0.95575996511f,
                0.944576716895f, 0.455478901428f,
                0.203683172197f, 0.0177149729234f,
                0.383628747896f, 0.379284571357f,
                0.945473563065f, 0.779431977074f,
                0.570420562284f, 0.576156483093f,
                0.674354533289f, 0.286346887653f,
                0.347776132801f, 0.734938485879f,
            };
        }
Ejemplo n.º 4
0
        public void Initialize(Device device, Form form, Panel panel, int resolutionX, int resolutionY)
        {
            m_ResolutionX = resolutionX;
            m_ResolutionY = resolutionY;

            m_FullResDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format = Format.R16G16B16A16_Float,
                m_HasDepth = false,
                m_NumSurfaces = 1,
                m_Height = resolutionY,
                m_Width = resolutionX
            };

            m_FullResAndDepthDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format = Format.R16G16B16A16_Float,
                m_HasDepth = true,
                m_NumSurfaces = 1,
                m_Height = resolutionY,
                m_Width = resolutionX
            };

            m_ResolvedColorDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format = Format.R8G8B8A8_UNorm,
                m_HasDepth = false,
                m_NumSurfaces = 1,
                m_Height = resolutionY,
                m_Width = resolutionX
            };

            m_LinearDepthDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format = Format.R32_Float,
                m_HasDepth = false,
                m_NumSurfaces = 1,
                m_Height = resolutionY,
                m_Width = resolutionX
            };
            m_SSAODescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format = Format.R8_UNorm,
                m_HasDepth = false,
                m_NumSurfaces = 1,
                m_Height = resolutionY,
                m_Width = resolutionX
            };

            m_SimpleSceneWrapper.Initialize(device, "sponza");

            TemporalSurfaceManager.InitializeRenderTarget("ResolvedColor", m_ResolvedColorDescriptor );

            TemporalSurfaceManager.InitializeRenderTarget("MotionVectors",
                new RenderTargetSet.RenderTargetDescriptor()
                {
                    m_Format = Format.R16G16_Float,
                    m_HasDepth = false,
                    m_NumSurfaces = 1,
                    m_Height = resolutionY,
                    m_Width = resolutionX
                });


            m_PostEffectsConstantBuffer = ShaderManager.CreateConstantBufferInstance("PostEffects", device);
            m_ForwardPassBuffer = ShaderManager.CreateConstantBufferInstance("ForwardPassBuffer", device);
            m_ViewportConstantBuffer = ShaderManager.CreateConstantBufferInstance("GlobalViewportBuffer", device);
            m_CurrentViewportBuffer = ShaderManager.CreateConstantBufferInstance("CurrentViewport", device);

            Vector3 min, max;
            m_SimpleSceneWrapper.GetSceneBounds(out min, out max);

            m_GIRenderer = new GlobalIlluminationRenderer(device, min, max);

            // Init passes
            m_ScatterDOFPass = new ScatterDOFPass();
            m_ScatterDOFPass.Initialize(device, resolutionX, resolutionY);

            m_ResolveHDRPass = new ResolveHDRPass();

            m_ResolveMotionVectorsPass = new ResolveMotionVectorsPass();

            m_ResolveTemporalPass = new ResolveTemporalMotionBasedPass();

            m_FxaaPass = new FxaaPass();

            m_SSAOPass = new SSAOEffectPass(device, resolutionX, resolutionY);

            m_LuminanceCalculations = new LuminanceCalculations(device, resolutionX, resolutionY);

            m_ShadowEVSMGenerator = new ShadowEVSMGenerator();

            m_VolumetricFog = new VolumetricFog();
            m_VolumetricFog.Initialize(device);

            m_StartTime = DateTime.Now;

            m_ViewportCamera.BindToInput(form, panel);

            POISSON_SAMPLES = new float[POISSON_SAMPLE_NUM * 2]
                {
                    0.655897408497f, 0.95575996511f, 
                    0.944576716895f, 0.455478901428f, 
                    0.203683172197f, 0.0177149729234f, 
                    0.383628747896f, 0.379284571357f, 
                    0.945473563065f, 0.779431977074f, 
                    0.570420562284f, 0.576156483093f, 
                    0.674354533289f, 0.286346887653f, 
                    0.347776132801f, 0.734938485879f, 
                };
        }
Ejemplo n.º 5
0
        public void Initialize(Device device, Form form, Panel panel, int resolutionX, int resolutionY)
        {
            m_ResolutionX = resolutionX;
            m_ResolutionY = resolutionY;

            m_FullResDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R16G16B16A16_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_FullResAndDepthDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R16G16B16A16_Float,
                m_HasDepth    = true,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_ResolvedColorDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R8G8B8A8_UNorm,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };
            m_LinearDepthDescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R32_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };
            m_SSAODescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R8_UNorm,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            };

            m_SimpleSceneWrapper.Initialize(device, "sponza");

            TemporalSurfaceManager.InitializeRenderTarget("ResolvedColor", m_ResolvedColorDescriptor);

            TemporalSurfaceManager.InitializeRenderTarget("MotionVectors",
                                                          new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R16G16_Float,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY,
                m_Width       = resolutionX
            });


            m_PostEffectsConstantBuffer = ShaderManager.CreateConstantBufferInstance("PostEffects", device);
            m_ForwardPassBuffer         = ShaderManager.CreateConstantBufferInstance("ForwardPassBuffer", device);
            m_ViewportConstantBuffer    = ShaderManager.CreateConstantBufferInstance("GlobalViewportBuffer", device);
            m_CurrentViewportBuffer     = ShaderManager.CreateConstantBufferInstance("CurrentViewport", device);

            Vector3 min, max;

            m_SimpleSceneWrapper.GetSceneBounds(out min, out max);

            m_GIRenderer = new GlobalIlluminationRenderer(device, min, max);

            // Init passes
            m_ScatterDOFPass = new ScatterDOFPass();
            m_ScatterDOFPass.Initialize(device, resolutionX, resolutionY);

            m_ResolveHDRPass = new ResolveHDRPass();

            m_ResolveMotionVectorsPass = new ResolveMotionVectorsPass();

            m_ResolveTemporalPass = new ResolveTemporalMotionBasedPass();

            m_FxaaPass = new FxaaPass();

            m_SSAOPass = new SSAOEffectPass(device, resolutionX, resolutionY);

            m_LuminanceCalculations = new LuminanceCalculations(device, resolutionX, resolutionY);

            m_ShadowEVSMGenerator = new ShadowEVSMGenerator();

            m_ViewportCamera.BindToInput(form, panel);
        }