Beispiel #1
0
        private bool UpSampleTexture()
        {
            // Set the render target to be the render to texture.
            UpSampleTexure.SetRenderTarget(D3D.DeviceContext);

            // Clear the render to texture.
            UpSampleTexure.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world and view matrices from the camera and d3d objects.
            Matrix cameraViewMatrix = Camera.BaseViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;

            // Get the ortho matrix from the render to texture since texture has different dimensions.
            Matrix orthoMatrix = UpSampleTexure.OrthoMatrix;

            // Turn off the Z buffer to begin all 2D rendering.
            D3D.TurnZBufferOff();

            // Put the full screen ortho window vertex and index buffers on the graphics pipeline to prepare them for drawing.
            if (!FullScreenWindow.Render(D3D.DeviceContext))
            {
                return(false);
            }

            // Render the full screen ortho window using the texture shader and the small sized final blurred render to texture resource.
            if (!TextureShader.Render(D3D.DeviceContext, FullScreenWindow.IndexCount, worldMatrix, cameraViewMatrix, orthoMatrix, VerticalBlurTexture.ShaderResourceView))
            {
                return(false);
            }

            // Turn the Z buffer back on now that all 2D rendering has completed.
            D3D.TurnZBufferOn();

            // Reset the render target back to the original back buffer and not the render to texture anymore.
            D3D.SetBackBufferRenderTarget();

            // Reset the viewport back to the original.
            D3D.ResetViewPort();

            return(true);
        }