Exemplo n.º 1
0
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = unchecked ((int)uint.MaxValue),
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat,
                StreamOutput          = new StreamOutputDescription() //find out how this should actually be done later
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;
            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for highlight objects.
            //

            GraphicsPipelineStateDescription highlightPsoDesc = opaquePsoDesc.Copy();

            // Change the depth test from < to <= so that if we draw the same triangle twice, it will
            // still pass the depth test. This is needed because we redraw the picked triangle with a
            // different material to highlight it. If we do not use <=, the triangle will fail the
            // depth test the 2nd time we try and draw it.
            highlightPsoDesc.DepthStencilState.DepthComparison = Comparison.LessEqual;

            // Standard transparency blending.
            var transparencyBlendDesc = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                LogicOpEnable         = false,
                SourceBlend           = BlendOption.SourceAlpha,
                DestinationBlend      = BlendOption.InverseSourceAlpha,
                BlendOperation        = BlendOperation.Add,
                SourceAlphaBlend      = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                AlphaBlendOperation   = BlendOperation.Add,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            highlightPsoDesc.BlendState.RenderTarget[0] = transparencyBlendDesc;
            _psos["highlight"] = Device.CreateGraphicsPipelineState(highlightPsoDesc);
        }
Exemplo n.º 2
0
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = unchecked ((int)uint.MaxValue),
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat,
                StreamOutput          = new StreamOutputDescription() //find out how this should actually be done later
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;
            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for sky.
            //

            GraphicsPipelineStateDescription skyPsoDesc = opaquePsoDesc.Copy();

            // The camera is inside the sky sphere, so just turn off culling.
            skyPsoDesc.RasterizerState.CullMode = CullMode.None;
            // Make sure the depth function is LESS_EQUAL and not just LESS.
            // Otherwise, the normalized depth values at z = 1 (NDC) will
            // fail the depth test if the depth buffer was cleared to 1.
            skyPsoDesc.DepthStencilState.DepthComparison = Comparison.LessEqual;
            skyPsoDesc.RootSignature = _rootSignature;
            skyPsoDesc.VertexShader  = _shaders["skyVS"];
            skyPsoDesc.PixelShader   = _shaders["skyPS"];
            _psos["sky"]             = Device.CreateGraphicsPipelineState(skyPsoDesc);
        }
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = int.MaxValue,
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat,
                StreamOutput          = new StreamOutputDescription() //find out how this should actually be done later
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;
            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for transparent objects.
            //

            GraphicsPipelineStateDescription transparentPsoDesc = opaquePsoDesc.Copy();
            var transparencyBlendDesc = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                LogicOpEnable         = false,
                SourceBlend           = BlendOption.SourceAlpha,
                DestinationBlend      = BlendOption.InverseSourceAlpha,
                BlendOperation        = BlendOperation.Add,
                SourceAlphaBlend      = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                AlphaBlendOperation   = BlendOperation.Add,
                LogicOp = LogicOperation.Noop,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            transparentPsoDesc.BlendState.RenderTarget[0] = transparencyBlendDesc;
            _psos["transparent"] = Device.CreateGraphicsPipelineState(transparentPsoDesc);

            //
            // PSO for alpha tested objects.
            //

            GraphicsPipelineStateDescription alphaTestedPsoDesc = opaquePsoDesc.Copy();

            alphaTestedPsoDesc.PixelShader = _shaders["alphaTestedPS"];
            alphaTestedPsoDesc.RasterizerState.CullMode = CullMode.None;
            _psos["alphaTested"] = Device.CreateGraphicsPipelineState(alphaTestedPsoDesc);

            //
            // PSO for drawing waves.
            //

            GraphicsPipelineStateDescription wavesRenderPSO = transparentPsoDesc.Copy();

            wavesRenderPSO.VertexShader = _shaders["wavesVS"];
            _psos["wavesRender"]        = Device.CreateGraphicsPipelineState(wavesRenderPSO);

            //
            // PSO for compositing post process.
            //

            GraphicsPipelineStateDescription compositePSO = opaquePsoDesc.Copy();

            compositePSO.RootSignature = _postProcessRootSignature;

            // Disable depth test.
            compositePSO.DepthStencilState.IsDepthEnabled  = false;
            compositePSO.DepthStencilState.DepthWriteMask  = DepthWriteMask.Zero;
            compositePSO.DepthStencilState.DepthComparison = Comparison.Always;
            compositePSO.VertexShader = _shaders["compositeVS"];
            compositePSO.PixelShader  = _shaders["compositePS"];
            _psos["composite"]        = Device.CreateGraphicsPipelineState(compositePSO);

            //
            // PSO for disturbing waves.
            //

            var wavesDisturbPSO = new ComputePipelineStateDescription
            {
                RootSignaturePointer = _wavesRootSignature,
                ComputeShader        = _shaders["wavesDisturbCS"],
                Flags = PipelineStateFlags.None
            };

            _psos["wavesDisturb"] = Device.CreateComputePipelineState(wavesDisturbPSO);

            //
            // PSO for updating waves.
            //

            var wavesUpdatePSO = new ComputePipelineStateDescription
            {
                RootSignaturePointer = _wavesRootSignature,
                ComputeShader        = _shaders["wavesUpdateCS"],
                Flags = PipelineStateFlags.None
            };

            _psos["wavesUpdate"] = Device.CreateComputePipelineState(wavesUpdatePSO);

            //
            // PSO for sobel.
            //

            var sobelPSO = new ComputePipelineStateDescription
            {
                RootSignaturePointer = _postProcessRootSignature,
                ComputeShader        = _shaders["sobelCS"],
                Flags = PipelineStateFlags.None
            };

            _psos["sobel"] = Device.CreateComputePipelineState(sobelPSO);
        }
Exemplo n.º 4
0
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = int.MaxValue,
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;

            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for transparent objects.
            //

            GraphicsPipelineStateDescription transparentPsoDesc = opaquePsoDesc.Copy();

            var transparencyBlendDesc = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                LogicOpEnable         = false, // TODO: API suggestion: Rename to IsLogicOpEnabled similar to IsBlendEnabled.
                SourceBlend           = BlendOption.SourceAlpha,
                DestinationBlend      = BlendOption.InverseSourceAlpha,
                BlendOperation        = BlendOperation.Add,
                SourceAlphaBlend      = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                AlphaBlendOperation   = BlendOperation.Add,
                LogicOp = LogicOperation.Noop,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            transparentPsoDesc.BlendState.RenderTarget[0] = transparencyBlendDesc;

            _psos["transparent"] = Device.CreateGraphicsPipelineState(transparentPsoDesc);

            //
            // PSO for alpha tested objects.
            //

            GraphicsPipelineStateDescription alphaTestedPsoDesc = opaquePsoDesc.Copy();

            alphaTestedPsoDesc.PixelShader = _shaders["alphaTestedPS"];
            alphaTestedPsoDesc.RasterizerState.CullMode = CullMode.None;

            _psos["alphaTested"] = Device.CreateGraphicsPipelineState(alphaTestedPsoDesc);
        }
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = unchecked ((int)uint.MaxValue),
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;
            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for shadow map pass.
            //

            var smapPsoDesc = opaquePsoDesc.Copy();

            smapPsoDesc.RasterizerState.DepthBias            = 100000;
            smapPsoDesc.RasterizerState.DepthBiasClamp       = 0.0f;
            smapPsoDesc.RasterizerState.SlopeScaledDepthBias = 1.0f;
            smapPsoDesc.VertexShader = _shaders["shadowVS"];
            smapPsoDesc.PixelShader  = _shaders["shadowOpaquePS"];
            // Shadow map pass does not have a render target.
            smapPsoDesc.RenderTargetFormats[0] = Format.Unknown;
            smapPsoDesc.RenderTargetCount      = 0;
            _psos["shadow_opaque"]             = Device.CreateGraphicsPipelineState(smapPsoDesc);

            //
            // PSO for debug layer.
            //

            var debugPsoDesc = opaquePsoDesc.Copy();

            debugPsoDesc.VertexShader = _shaders["debugVS"];
            debugPsoDesc.PixelShader  = _shaders["debugPS"];
            _psos["debug"]            = Device.CreateGraphicsPipelineState(debugPsoDesc);

            //
            // PSO for sky.
            //

            GraphicsPipelineStateDescription skyPsoDesc = opaquePsoDesc.Copy();

            // The camera is inside the sky sphere, so just turn off culling.
            skyPsoDesc.RasterizerState.CullMode = CullMode.None;
            // Make sure the depth function is LESS_EQUAL and not just LESS.
            // Otherwise, the normalized depth values at z = 1 (NDC) will
            // fail the depth test if the depth buffer was cleared to 1.
            skyPsoDesc.DepthStencilState.DepthComparison = Comparison.LessEqual;
            skyPsoDesc.VertexShader = _shaders["skyVS"];
            skyPsoDesc.PixelShader  = _shaders["skyPS"];
            _psos["sky"]            = Device.CreateGraphicsPipelineState(skyPsoDesc);
        }
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = unchecked ((int)0xFFFFFFFF),
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat,
                StreamOutput          = new StreamOutputDescription() //find out how this should actually be done later
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;

            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for transparent objects.
            //

            GraphicsPipelineStateDescription transparentPsoDesc = opaquePsoDesc.Copy();

            var transparencyBlendDesc = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                LogicOpEnable         = false,
                SourceBlend           = BlendOption.SourceAlpha,
                DestinationBlend      = BlendOption.InverseSourceAlpha,
                BlendOperation        = BlendOperation.Add,
                SourceAlphaBlend      = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                AlphaBlendOperation   = BlendOperation.Add,
                LogicOp = LogicOperation.Noop,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            transparentPsoDesc.BlendState.RenderTarget[0] = transparencyBlendDesc;

            _psos["transparent"] = Device.CreateGraphicsPipelineState(transparentPsoDesc);

            //
            // PSO for alpha tested objects.
            //

            GraphicsPipelineStateDescription alphaTestedPsoDesc = opaquePsoDesc.Copy();

            alphaTestedPsoDesc.PixelShader = _shaders["alphaTestedPS"];
            alphaTestedPsoDesc.RasterizerState.CullMode = CullMode.None;

            _psos["alphaTested"] = Device.CreateGraphicsPipelineState(alphaTestedPsoDesc);

            //
            // PSO for tree sprites.
            //

            GraphicsPipelineStateDescription treeSpritePsoDesc = opaquePsoDesc.Copy();

            treeSpritePsoDesc.VertexShader             = _shaders["treeSpriteVS"];
            treeSpritePsoDesc.GeometryShader           = _shaders["treeSpriteGS"];
            treeSpritePsoDesc.PixelShader              = _shaders["treeSpritePS"];
            treeSpritePsoDesc.PrimitiveTopologyType    = PrimitiveTopologyType.Point;
            treeSpritePsoDesc.InputLayout              = _treeSpriteInputLayout;
            treeSpritePsoDesc.RasterizerState.CullMode = CullMode.None;

            _psos["treeSprites"] = Device.CreateGraphicsPipelineState(treeSpritePsoDesc);
        }
Exemplo n.º 7
0
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = int.MaxValue,
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat,
                StreamOutput          = new StreamOutputDescription() //find out how this should actually be done later
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;

            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for transparent objects.
            //

            GraphicsPipelineStateDescription transparentPsoDesc = opaquePsoDesc.Copy();

            var transparencyBlendDesc = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                LogicOpEnable         = false, // TODO: rename to IsLogicOpEnabled
                SourceBlend           = BlendOption.SourceAlpha,
                DestinationBlend      = BlendOption.InverseSourceAlpha,
                BlendOperation        = BlendOperation.Add,
                SourceAlphaBlend      = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                AlphaBlendOperation   = BlendOperation.Add,
                LogicOp = LogicOperation.Noop,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            transparentPsoDesc.BlendState.RenderTarget[0] = transparencyBlendDesc;

            _psos["transparent"] = Device.CreateGraphicsPipelineState(transparentPsoDesc);

            //
            // PSO for alpha tested objects.
            //

            GraphicsPipelineStateDescription alphaTestedPsoDesc = opaquePsoDesc.Copy();

            alphaTestedPsoDesc.PixelShader = _shaders["alphaTestedPS"];
            alphaTestedPsoDesc.RasterizerState.CullMode = CullMode.None;

            _psos["alphaTested"] = Device.CreateGraphicsPipelineState(alphaTestedPsoDesc);

            //
            // PSO for horizontal blur.
            //

            var horzBlurPso = new ComputePipelineStateDescription
            {
                RootSignaturePointer = _postProcessRootSignature,
                ComputeShader        = _shaders["horzBlurCS"],
                Flags = PipelineStateFlags.None
            };

            _psos["horzBlur"] = Device.CreateComputePipelineState(horzBlurPso);

            //
            // PSO for vertical blur.
            //

            var vertBlurPso = new ComputePipelineStateDescription
            {
                RootSignaturePointer = _postProcessRootSignature,
                ComputeShader        = _shaders["vertBlurCS"],
                Flags = PipelineStateFlags.None
            };

            _psos["vertBlur"] = Device.CreateComputePipelineState(vertBlurPso);
        }
Exemplo n.º 8
0
        private void BuildPSOs()
        {
            //
            // PSO for opaque objects.
            //

            var opaquePsoDesc = new GraphicsPipelineStateDescription
            {
                InputLayout           = _inputLayout,
                RootSignature         = _rootSignature,
                VertexShader          = _shaders["standardVS"],
                PixelShader           = _shaders["opaquePS"],
                RasterizerState       = RasterizerStateDescription.Default(),
                BlendState            = BlendStateDescription.Default(),
                DepthStencilState     = DepthStencilStateDescription.Default(),
                SampleMask            = unchecked ((int)0xFFFFFFFF),
                PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
                RenderTargetCount     = 1,
                SampleDescription     = new SampleDescription(MsaaCount, MsaaQuality),
                DepthStencilFormat    = DepthStencilFormat,
                StreamOutput          = new StreamOutputDescription() //find out how this should actually be done later
            };

            opaquePsoDesc.RenderTargetFormats[0] = BackBufferFormat;
            _psos["opaque"] = Device.CreateGraphicsPipelineState(opaquePsoDesc);

            //
            // PSO for transparent objects.
            //

            GraphicsPipelineStateDescription transparentPsoDesc = opaquePsoDesc.Copy();
            var transparencyBlendDesc = new RenderTargetBlendDescription
            {
                IsBlendEnabled        = true,
                LogicOpEnable         = false,
                SourceBlend           = BlendOption.SourceAlpha,
                DestinationBlend      = BlendOption.InverseSourceAlpha,
                BlendOperation        = BlendOperation.Add,
                SourceAlphaBlend      = BlendOption.One,
                DestinationAlphaBlend = BlendOption.Zero,
                AlphaBlendOperation   = BlendOperation.Add,
                LogicOp = LogicOperation.Noop,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            transparentPsoDesc.BlendState.RenderTarget[0] = transparencyBlendDesc;
            _psos["transparent"] = Device.CreateGraphicsPipelineState(transparentPsoDesc);

            //
            // PSO for marking stencil mirrors.
            //

            // We are not rendering backfacing polygons, so these settings do not matter.
            var backFaceDSO = new DepthStencilOperationDescription
            {
                FailOperation      = StencilOperation.Keep,
                DepthFailOperation = StencilOperation.Keep,
                PassOperation      = StencilOperation.Replace,
                Comparison         = Comparison.Always
            };

            var mirrorBlendState = BlendStateDescription.Default();

            mirrorBlendState.RenderTarget[0].RenderTargetWriteMask = 0;
            var mirrorDSS = new DepthStencilStateDescription
            {
                IsDepthEnabled   = true,
                DepthWriteMask   = DepthWriteMask.Zero,
                DepthComparison  = Comparison.Less,
                IsStencilEnabled = true,
                StencilReadMask  = 0xff,
                StencilWriteMask = 0xff,

                FrontFace = new DepthStencilOperationDescription
                {
                    FailOperation      = StencilOperation.Keep,
                    DepthFailOperation = StencilOperation.Keep,
                    PassOperation      = StencilOperation.Replace,
                    Comparison         = Comparison.Always
                },
                BackFace = backFaceDSO
            };

            GraphicsPipelineStateDescription markMirrorsPsoDesc = opaquePsoDesc.Copy();

            markMirrorsPsoDesc.BlendState        = mirrorBlendState;
            markMirrorsPsoDesc.DepthStencilState = mirrorDSS;
            _psos["markStencilMirrors"]          = Device.CreateGraphicsPipelineState(markMirrorsPsoDesc);

            //
            // PSO for stencil reflections.
            //

            var reflectionDSS = new DepthStencilStateDescription
            {
                IsDepthEnabled   = true,
                DepthWriteMask   = DepthWriteMask.All,
                DepthComparison  = Comparison.Less,
                IsStencilEnabled = true,
                StencilReadMask  = 0xff,
                StencilWriteMask = 0xff,

                FrontFace = new DepthStencilOperationDescription
                {
                    FailOperation      = StencilOperation.Keep,
                    DepthFailOperation = StencilOperation.Keep,
                    PassOperation      = StencilOperation.Keep,
                    Comparison         = Comparison.Equal
                },
                BackFace = backFaceDSO
            };

            GraphicsPipelineStateDescription drawReflectionsPsoDesc = opaquePsoDesc.Copy();

            drawReflectionsPsoDesc.DepthStencilState        = reflectionDSS;
            drawReflectionsPsoDesc.RasterizerState.CullMode = CullMode.Back;
            drawReflectionsPsoDesc.RasterizerState.IsFrontCounterClockwise = true;
            _psos["drawStencilReflections"] = Device.CreateGraphicsPipelineState(drawReflectionsPsoDesc);

            //
            // PSO for shadow objects.
            //

            var shadowDSS = new DepthStencilStateDescription
            {
                IsDepthEnabled   = true,
                DepthWriteMask   = DepthWriteMask.All,
                DepthComparison  = Comparison.Less,
                IsStencilEnabled = true,
                StencilReadMask  = 0xff,
                StencilWriteMask = 0xff,

                FrontFace = new DepthStencilOperationDescription
                {
                    FailOperation      = StencilOperation.Keep,
                    DepthFailOperation = StencilOperation.Keep,
                    PassOperation      = StencilOperation.Increment,
                    Comparison         = Comparison.Equal
                },
                BackFace = backFaceDSO
            };

            GraphicsPipelineStateDescription shadowPsoDesc = transparentPsoDesc.Copy();

            shadowPsoDesc.DepthStencilState = shadowDSS;
            _psos["shadow"] = Device.CreateGraphicsPipelineState(shadowPsoDesc);
        }