Beispiel #1
0
        public void ApplyVisualEffects(View view)
        {
            Debug.Assert(view != null);

            // Retrieve layer holder for the given format
            RenderTargetArrayHolder targetHolder = SelectRenderTargetArray(view);

            // Prepare device
            renderer.Device.OutputMerger.BlendState        = visualEffectsBlendState;
            renderer.Device.OutputMerger.DepthStencilState = depthStencilState;
            renderer.Device.OutputMerger.BlendFactor       = new Color4(1, 1, 1, 1);
            renderer.Device.OutputMerger.BlendSampleMask   = -1;
            renderer.Device.Rasterizer.State = rasterizerState;

            // Apply effects
            renderer.Device.OutputMerger.SetTargets((DepthStencilView)null, targetHolder.RenderTargetViewAsArray);
            renderer.Device.ClearRenderTargetView(targetHolder.RenderTargetViewAsArray, new Color4(0, 0, 0, 0));
            foreach (VisualEffect visualEffect in visualEffects)
            {
                visualEffect.Apply(view, renderer.KBufferManager.SetupGeometryBufferTargets);
            }

            // Blend layers
            renderer.Device.OutputMerger.SetTargets((DepthStencilView)null, view.Target);
            renderer.Device.OutputMerger.BlendState = blenderBlendState;
            blender.Blend(targetHolder.ShaderResourceViewAsArray);
        }
Beispiel #2
0
        private RenderTargetArrayHolder SelectRenderTargetArray(View view)
        {
            Format format = view.Target.Description.Format;

            if (renderTargetsForGivenFormat.ContainsKey(format))
            {
                return(renderTargetsForGivenFormat[format]);
            }

            var newArrayHolder = new RenderTargetArrayHolder(renderer.Device, renderer.Configuration.BackBufferWidth,
                                                             renderer.Configuration.BackBufferHeight,
                                                             view.Target.Description.Format,
                                                             renderer.KBufferManager.Configuration.LayerCount);

            renderTargetsForGivenFormat.Add(format, newArrayHolder);
            return(newArrayHolder);
        }
        private RenderTargetArrayHolder SelectRenderTargetArray(View view)
        {
            Format format = view.Target.Description.Format;

            if (renderTargetsForGivenFormat.ContainsKey(format))
                return renderTargetsForGivenFormat[format];

            var newArrayHolder = new RenderTargetArrayHolder(renderer.Device, renderer.Configuration.BackBufferWidth,
                                                             renderer.Configuration.BackBufferHeight,
                                                             view.Target.Description.Format,
                                                             renderer.KBufferManager.Configuration.LayerCount);
            renderTargetsForGivenFormat.Add(format, newArrayHolder);
            return newArrayHolder;
        }