Inheritance: IRenderHelper
Example #1
0
        public void OnInitialize(DeviceContextHolder holder) {
            _effect = holder.GetEffect<EffectPpHdr>();
            _blurHelper = holder.GetHelper<BlurHelper>();

            _textures = Enumerable.Range(0, DownsamplerAdaptationCycles)
                          .Select(x => TargetResourceTexture.Create(Format.R16G16B16A16_Float))
                          .ToArray();

            _averateColor = Enumerable.Range(0, 2).Select(x => {
                var t = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
                t.Resize(holder, 1, 1);
                return t;
            }).ToArray();

            _newAverageColor = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _newAverageColor.Resize(holder, 1, 1);

            _bloomTexture = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _tempTexture = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
        }
Example #2
0
        public void OnInitialize(DeviceContextHolder holder)
        {
            _effect     = holder.GetEffect <EffectPpHdr>();
            _blurHelper = holder.GetHelper <BlurHelper>();

            _textures = Enumerable.Range(0, DownsamplerAdaptationCycles)
                        .Select(x => TargetResourceTexture.Create(Format.R16G16B16A16_Float))
                        .ToArray();

            _averateColor = Enumerable.Range(0, 2).Select(x => {
                var t = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
                t.Resize(holder, 1, 1, null);
                return(t);
            }).ToArray();

            _newAverageColor = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _newAverageColor.Resize(holder, 1, 1, null);

            _bloomTexture = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
            _tempTexture  = TargetResourceTexture.Create(Format.R16G16B16A16_Float);
        }
Example #3
0
        protected override void DrawInner() {
            DrawPrepare();

            DeviceContext.ClearRenderTargetView(_buffer.TargetView, Color.Gray);
            DeviceContext.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);
            DeviceContext.OutputMerger.SetTargets(DepthStencilView, _buffer.TargetView);

            DeviceContext.OutputMerger.DepthStencilState = null;
            DeviceContext.OutputMerger.BlendState = null;
            DeviceContext.Rasterizer.State = ShowWireframe ? _wireframeRasterizerState : null;

            DeviceContext.OutputMerger.DepthStencilState = DeviceContextHolder.LessEqualDepthState;
            Scene.Draw(DeviceContextHolder, ActualCamera, SpecialRenderMode.Simple);

            DeviceContext.OutputMerger.DepthStencilState = DeviceContextHolder.ReadOnlyDepthState;
            Scene.Draw(DeviceContextHolder, ActualCamera, SpecialRenderMode.SimpleTransparent);

            DrawAfter();

            DeviceContext.OutputMerger.DepthStencilState = null;
            DeviceContext.OutputMerger.BlendState = null;
            DeviceContext.Rasterizer.State = null;

            ShaderResourceView result;
            if (UseBloom) {
                if (_hdr == null) {
                    _hdr = DeviceContextHolder.GetEffect<EffectPpHdr>();
                    _blur = DeviceContextHolder.GetHelper<BlurHelper>();
                }

                DeviceContext.OutputMerger.SetTargets(_buffer1.TargetView);
                DeviceContext.ClearRenderTargetView(_buffer1.TargetView, ColorTransparent);

                DeviceContextHolder.PrepareQuad(_hdr.LayoutPT);
                _hdr.FxInputMap.SetResource(_buffer.View);
                _hdr.TechBloom.DrawAllPasses(DeviceContext, 6);
                
                _blur.Blur(DeviceContextHolder, _buffer1, _buffer2, 1f, 2);

                DeviceContext.OutputMerger.SetTargets(_buffer2.TargetView);

                _hdr.FxInputMap.SetResource(_buffer.View);
                _hdr.FxBloomMap.SetResource(_buffer1.View);
                _hdr.TechCombine.DrawAllPasses(DeviceContext, 6);

                result = _buffer2.View;
            } else {
                result = _buffer.View;
            }

            DeviceContext.ClearRenderTargetView(RenderTargetView, ColorTransparent);
            if (UseFxaa) {
                DeviceContextHolder.GetHelper<FxaaHelper>().Draw(DeviceContextHolder, result, RenderTargetView);
            } else {
                DeviceContextHolder.GetHelper<CopyHelper>().Draw(DeviceContextHolder, result, RenderTargetView);
            }
        }