Exemple #1
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_SSAODescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = Format.R8_UNorm,
                m_HasDepth    = false,
                m_NumSurfaces = 1,
                m_Height      = resolutionY / 2,
                m_Width       = resolutionX / 2
            };

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

            m_SimpleSceneWrapper.Initialize(device, "sponza");

            TemporalSurfaceManager.InitializeRenderTarget("SceneMainRender", m_FullResAndDepthDescriptor);
            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_DepthOperationsPass = new DepthOperationsPass(resolutionX, resolutionY);

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

            m_SSReflectionsPass = new SSReflectionsEffectPass(device, resolutionX / 2, resolutionY / 2);

            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,
            };

            m_CubeObject         = TextureObject.CreateCubeTexture(device, 256, 256, 1, Format.R16G16B16A16_Float, false, true);
            m_CubeObjectFiltered = TextureObject.CreateCubeTexture(device, 256, 256, 7, Format.R16G16B16A16_Float, false, true);
            m_CubeDepthObject    = TextureObject.CreateCubeTexture(device, 256, 256, 1, Format.R32_Typeless, true, true);
        }
Exemple #2
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_SSAODescriptor = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format = Format.R8_UNorm,
                m_HasDepth = false,
                m_NumSurfaces = 1,
                m_Height = resolutionY / 2,
                m_Width = resolutionX / 2
            };

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

            m_SimpleSceneWrapper.Initialize(device, "sponza");

            TemporalSurfaceManager.InitializeRenderTarget("SceneMainRender", m_FullResAndDepthDescriptor);
            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_DepthOperationsPass = new DepthOperationsPass(resolutionX, resolutionY);

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

            m_SSReflectionsPass = new SSReflectionsEffectPass(device, resolutionX / 2, resolutionY / 2);

            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,
                };

            m_CubeObject = TextureObject.CreateCubeTexture(device, 256, 256, 1, Format.R16G16B16A16_Float, false, true);
            m_CubeObjectFiltered = TextureObject.CreateCubeTexture(device, 256, 256, 7, Format.R16G16B16A16_Float, false, true);
            m_CubeDepthObject = TextureObject.CreateCubeTexture(device, 256, 256, 1, Format.R32_Typeless, true, true);
        }