예제 #1
0
        private void BlurAmbientMap(GraphicsCommandList cmdList, FrameResource currFrame, int blurCount)
        {
            cmdList.PipelineState = _ssaoBlurPso;

            long ssaoCBAddress = currFrame.SsaoCB.Resource.GPUVirtualAddress;

            cmdList.SetGraphicsRootConstantBufferView(0, ssaoCBAddress);

            for (int i = 0; i < blurCount; i++)
            {
                BlurAmbientMap(cmdList, true);
                BlurAmbientMap(cmdList, false);
            }
        }
예제 #2
0
        public void ComputeSsao(GraphicsCommandList cmdList, FrameResource currFrame, int blurCount)
        {
            cmdList.SetViewports(_viewport);
            cmdList.SetScissorRectangles(_scissorRectangle);

            // We compute the initial SSAO to AmbientMap0.

            // Change to RENDER_TARGET.
            cmdList.ResourceBarrierTransition(_ambientMap0, ResourceStates.GenericRead, ResourceStates.RenderTarget);

            cmdList.ClearRenderTargetView(_ambientMap0CpuRtv, Color.White);

            // Specify the buffers we are going to render to.
            cmdList.SetRenderTargets(1, _ambientMap0CpuRtv, null);

            // Bind the constant buffer for this pass.
            long ssaoCBAddress = currFrame.SsaoCB.Resource.GPUVirtualAddress;

            cmdList.SetGraphicsRootConstantBufferView(0, ssaoCBAddress);
            cmdList.SetGraphicsRoot32BitConstant(1, 0, 0);

            // Bind the normal and depth maps.
            cmdList.SetGraphicsRootDescriptorTable(2, _normalMapGpuSrv);

            // Bind the random vector map.
            cmdList.SetGraphicsRootDescriptorTable(3, _randomVectorMapGpuSrv);

            cmdList.PipelineState = _ssaoPso;

            // Draw fullscreen quad.
            cmdList.SetVertexBuffers(0, null, 0);
            cmdList.SetIndexBuffer(null);
            cmdList.PrimitiveTopology = PrimitiveTopology.TriangleList;
            cmdList.DrawInstanced(6, 1, 0, 0);

            // Change back to GENERIC_READ so we can read the texture in a shader.
            cmdList.ResourceBarrierTransition(_ambientMap0, ResourceStates.RenderTarget, ResourceStates.GenericRead);

            BlurAmbientMap(cmdList, currFrame, blurCount);
        }