Пример #1
0
        public void Draw(DeviceContextHolder holder, ShaderResourceView view, TargetResourceTexture temporary)
        {
            // preparation
            holder.SaveRenderTargetAndViewport();
            holder.QuadBuffers.Prepare(holder.DeviceContext, _effect.LayoutPT);

            // update those small texture
            UpdateNewAverateColor(holder, view);
            UpdateAdaptation(holder);

            holder.RestoreRenderTargetAndViewport();
            holder.DeviceContext.OutputMerger.SetTargets(temporary.TargetView);
            holder.DeviceContext.ClearRenderTargetView(temporary.TargetView, BaseRenderer.ColorTransparent);

            _effect.FxInputMap.SetResource(view);
            _effect.FxBrightnessMap.SetResource(GetAdaptationTexture().View);
            _effect.TechTonemap.DrawAllPasses(holder.DeviceContext, 6);

            // update bloom texture (bright areas)
            UpdateBloom(holder, temporary.View);

            if (BloomDebug)
            {
                holder.RestoreRenderTargetAndViewport();
                _effect.FxInputMap.SetResource(_bloomTexture.View);
                _effect.TechCopy.DrawAllPasses(holder.DeviceContext, 6);
                return;
            }

            // reset viewport
            holder.RestoreRenderTargetAndViewport();

            _effect.FxInputMap.SetResource(temporary.View);
            _effect.FxBloomMap.SetResource(_bloomTexture.View);
            _effect.TechCombine.DrawAllPasses(holder.DeviceContext, 6);
        }
Пример #2
0
        public void DrawScene(DeviceContextHolder holder, IReflectionDraw draw)
        {
            holder.SaveRenderTargetAndViewport();
            holder.DeviceContext.Rasterizer.SetViewports(_viewport);
            for (var i = 0; i < 6; i++)
            {
                holder.DeviceContext.ClearRenderTargetView(_targetView[i], BackgroundColor);
                holder.DeviceContext.ClearDepthStencilView(_depthTargetView,
                                                           DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil,
                                                           1.0f, 0);
                holder.DeviceContext.OutputMerger.SetTargets(_depthTargetView, _targetView[i]);
                draw.DrawSceneForReflection(holder, _cameras[i]);
            }

            holder.DeviceContext.GenerateMips(_view);
            holder.RestoreRenderTargetAndViewport();
        }
Пример #3
0
        public void Clear(DeviceContextHolder holder)
        {
            holder.SaveRenderTargetAndViewport();

            holder.DeviceContext.Rasterizer.SetViewports(_viewport);
            holder.DeviceContext.OutputMerger.DepthStencilState = null;
            holder.DeviceContext.OutputMerger.BlendState        = null;
            holder.DeviceContext.Rasterizer.State = _rasterizerState;

            foreach (var split in Splits)
            {
                holder.DeviceContext.OutputMerger.SetTargets(split.Buffer.DepthView);
                holder.DeviceContext.ClearDepthStencilView(split.Buffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);
            }

            holder.DeviceContext.Rasterizer.State = null;
            holder.DeviceContext.OutputMerger.DepthStencilState = null;
            holder.RestoreRenderTargetAndViewport();
        }
Пример #4
0
        public void DrawScene(DeviceContextHolder holder, IShadowsDraw draw)
        {
            holder.SaveRenderTargetAndViewport();

            holder.DeviceContext.Rasterizer.SetViewports(_viewport);
            holder.DeviceContext.OutputMerger.DepthStencilState = null;
            holder.DeviceContext.OutputMerger.BlendState        = null;
            holder.DeviceContext.Rasterizer.State = _rasterizerState;

            foreach (var split in Splits)
            {
                holder.DeviceContext.OutputMerger.SetTargets(split.Buffer.DepthView);
                holder.DeviceContext.ClearDepthStencilView(split.Buffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);
                draw.DrawSceneForShadows(holder, split.Camera);
                holder.DeviceContext.GenerateMips(split.Buffer.View);
            }

            holder.DeviceContext.Rasterizer.State = null;
            holder.DeviceContext.OutputMerger.DepthStencilState = null;
            holder.RestoreRenderTargetAndViewport();
        }
Пример #5
0
        public void DrawScene(DeviceContextHolder holder, IReflectionDraw draw) {
            holder.SaveRenderTargetAndViewport();
            holder.DeviceContext.Rasterizer.SetViewports(_viewport);
            for (var i = 0; i < 6; i++) {
                holder.DeviceContext.ClearRenderTargetView(_targetView[i], new Color4(0));
                holder.DeviceContext.ClearDepthStencilView(_depthTargetView,
                                                           DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil,
                                                           1.0f, 0);
                holder.DeviceContext.OutputMerger.SetTargets(_depthTargetView, _targetView[i]);
                draw.DrawSceneForReflection(holder, _cameras[i]);
            }

            holder.DeviceContext.GenerateMips(_view);
            holder.RestoreRenderTargetAndViewport();
        }
Пример #6
0
        public void DrawScene(DeviceContextHolder holder, IShadowsDraw draw) {
            holder.SaveRenderTargetAndViewport();

            holder.DeviceContext.Rasterizer.SetViewports(_viewport);
            holder.DeviceContext.OutputMerger.DepthStencilState = null;
            holder.DeviceContext.OutputMerger.BlendState = null;
            holder.DeviceContext.Rasterizer.State = _rasterizerState;

            foreach (var split in Splits) {
                holder.DeviceContext.OutputMerger.SetTargets(split.Buffer.DepthView);
                holder.DeviceContext.ClearDepthStencilView(split.Buffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0);
                draw.DrawSceneForShadows(holder, split.Camera);
                holder.DeviceContext.GenerateMips(split.Buffer.View);
            }

            holder.DeviceContext.Rasterizer.State = null;
            holder.DeviceContext.OutputMerger.DepthStencilState = null;
            holder.RestoreRenderTargetAndViewport();
        }
Пример #7
0
        public void Draw(DeviceContextHolder holder, ShaderResourceView view, TargetResourceTexture temporary) {
            // preparation
            holder.SaveRenderTargetAndViewport();
            holder.QuadBuffers.Prepare(holder.DeviceContext, _effect.LayoutPT);

            // update those small texture
            UpdateNewAverateColor(holder, view);
            UpdateAdaptation(holder);

            holder.RestoreRenderTargetAndViewport();
            holder.DeviceContext.OutputMerger.SetTargets(temporary.TargetView);
            holder.DeviceContext.ClearRenderTargetView(temporary.TargetView, BaseRenderer.ColorTransparent);

            _effect.FxInputMap.SetResource(view);
            _effect.FxBrightnessMap.SetResource(GetAdaptationTexture().View);
            _effect.TechTonemap.DrawAllPasses(holder.DeviceContext, 6);

            // update bloom texture (bright areas)
            UpdateBloom(holder, temporary.View);

            if (BloomDebug) {
                holder.RestoreRenderTargetAndViewport();
                _effect.FxInputMap.SetResource(_bloomTexture.View);
                _effect.TechCopy.DrawAllPasses(holder.DeviceContext, 6);
                return;
            }

            // reset viewport
            holder.RestoreRenderTargetAndViewport();

            _effect.FxInputMap.SetResource(temporary.View);
            _effect.FxBloomMap.SetResource(_bloomTexture.View);
            _effect.TechCombine.DrawAllPasses(holder.DeviceContext, 6);
        }