Esempio n. 1
0
        private void SetupRenderPassViewport(IRenderContext renderContext, IRenderPass pass)
        {
            var renderPassWithViewport = pass as IRenderPassWithViewport;

            Viewport newViewport;

            if (renderPassWithViewport?.Viewport != null)
            {
                newViewport = renderPassWithViewport.Viewport.Value;
            }
            else
            {
                var size = _backBufferDimensions.GetSize(renderContext.GraphicsDevice);
                newViewport = new Viewport(
                    0,
                    0,
                    size.Width,
                    size.Height);
            }

            var currentViewport = renderContext.GraphicsDevice.Viewport;

            if (currentViewport.X != newViewport.X ||
                currentViewport.Y != newViewport.Y ||
                currentViewport.Width != newViewport.Width ||
                currentViewport.Height != newViewport.Height)
            {
                // The viewport is different, assign it to the GPU.
                renderContext.GraphicsDevice.Viewport = newViewport;
            }
        }
Esempio n. 2
0
        private void SetupRenderPassViewport(IRenderContext renderContext, IRenderPass pass)
        {
            var renderPassWithViewport = pass as IRenderPassWithViewport;

            Viewport newViewport;

            if (renderPassWithViewport?.Viewport != null)
            {
                newViewport = renderPassWithViewport.Viewport.Value;
            }
            else
            {
                newViewport = new Viewport(
                    0,
                    0,
                    renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth,
                    renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight);
            }

            var currentViewport = renderContext.GraphicsDevice.Viewport;

            if (currentViewport.X != newViewport.X ||
                currentViewport.Y != newViewport.Y ||
                currentViewport.Width != newViewport.Width ||
                currentViewport.Height != newViewport.Height)
            {
                // The viewport is different, assign it to the GPU.
                renderContext.GraphicsDevice.Viewport = newViewport;
            }
        }
Esempio n. 3
0
 public void RemoveFixedRenderPass(IRenderPass renderPass)
 {
     if (renderPass.IsPostProcessingPass)
     {
         _postProcessingRenderPasses.Remove(renderPass);
     }
     else
     {
         _standardRenderPasses.Remove(renderPass);
     }
 }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass,
            RenderTarget2D postProcessingSource)
        {
            _renderTarget = _renderTargetBackBufferUtilities.UpdateRenderTarget(_renderTarget, gameContext);

            // Blit to the capture target.
            _graphicsBlit.Blit(renderContext, postProcessingSource, _renderTarget);

            // Blit to the output.
            _graphicsBlit.Blit(renderContext, postProcessingSource);
        }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass,
            RenderTarget2D postProcessingSource)
        {
            if (RenderPipelineStateAvailable != null)
            {
                RenderPipelineStateAvailable(postProcessingSource);
            }

            // Blit to the output.
            _graphicsBlit.Blit(renderContext, postProcessingSource);
        }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            // TODO Make iterations work.

            _blurEffect.NativeEffect.Parameters["PixelWidth"].SetValue(1f/postProcessingSource.Width);
            _blurEffect.NativeEffect.Parameters["PixelHeight"].SetValue(1f/postProcessingSource.Height);
            //_blurEffect.CurrentTechnique.Passes[0].Apply();

            // Parameters will get applied when blitting occurs.

            _graphicsBlit.Blit(renderContext, postProcessingSource, null, _blurEffect);
        }
        public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
        {
            if (EnabledLayers.Count == 0)
            {
                return;
            }

            var world = renderContext.World;
            renderContext.World = Matrix.Identity;

            _basicEffect.NativeEffect.Parameters["World"].SetValue(renderContext.World);
            _basicEffect.NativeEffect.Parameters["View"].SetValue(renderContext.View);
            _basicEffect.NativeEffect.Parameters["Projection"].SetValue(renderContext.Projection);

            foreach (var pass in _basicEffect.NativeEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                if (Lines.Count > 0)
                {
                    // Batch render all lines.
                    var lines = Lines.ToArray();
                    for (var i = 0; i < lines.Length; i += 1000)
                    {
                        renderContext.GraphicsDevice.DrawUserPrimitives(
                            PrimitiveType.LineList,
                            lines,
                            i,
                            lines.Length - i > 1000 ? 500 : (lines.Length - i) / 2);
                    }
                }

                if (Triangles.Count > 0)
                {
                    // Batch render all triangles.
                    var triangles = Triangles.ToArray();
                    for (var i = 0; i < triangles.Length; i += 1500)
                    {
                        renderContext.GraphicsDevice.DrawUserPrimitives(
                            PrimitiveType.TriangleList,
                            triangles,
                            i,
                            triangles.Length - i > 1500 ? 500 : (triangles.Length - i) / 3);
                    }
                }
            }

            renderContext.World = world;
            
            renderContext.GraphicsDevice.RasterizerState = _oldRasterizerState;
            renderContext.GraphicsDevice.DepthStencilState = _oldDepthState;
        }
 public DefaultRenderPipeline(
     IGraphicsBlit graphicsBlit,
     IRenderTargetBackBufferUtilities renderTargetBackBufferUtilities)
 {
     _graphicsBlit = graphicsBlit;
     _renderTargetBackBufferUtilities     = renderTargetBackBufferUtilities;
     _standardRenderPasses                = new List <IRenderPass>();
     _postProcessingRenderPasses          = new List <IRenderPass>();
     _transientStandardRenderPasses       = new List <IRenderPass>();
     _transientPostProcessingRenderPasses = new List <IRenderPass>();
     _renderPass        = null;
     _isFirstRenderPass = false;
 }
Esempio n. 9
0
        public IRenderPass AddFixedRenderPass(IRenderPass renderPass)
        {
            if (renderPass.IsPostProcessingPass)
            {
                _postProcessingRenderPasses.Add(renderPass);
            }
            else
            {
                _standardRenderPasses.Add(renderPass);
            }

            return(renderPass);
        }
Esempio n. 10
0
        public IRenderPass AppendTransientRenderPass(IRenderPass renderPass)
        {
            if (renderPass.IsPostProcessingPass)
            {
                _transientPostProcessingRenderPasses.Add(renderPass);
            }
            else
            {
                _transientStandardRenderPasses.Add(renderPass);
            }

            return(renderPass);
        }
Esempio n. 11
0
 public DefaultRenderPipeline(
     IGraphicsBlit graphicsBlit,
     IRenderTargetBackBufferUtilities renderTargetBackBufferUtilities)
 {
     _graphicsBlit = graphicsBlit;
     _renderTargetBackBufferUtilities = renderTargetBackBufferUtilities;
     _standardRenderPasses = new List<IRenderPass>();
     _postProcessingRenderPasses = new List<IRenderPass>();
     _transientStandardRenderPasses = new List<IRenderPass>();
     _transientPostProcessingRenderPasses = new List<IRenderPass>();
     _renderPass = null;
     _isFirstRenderPass = false;
 }
Esempio n. 12
0
        public IRenderPass AddFixedRenderPass(IRenderPass renderPass)
        {
            if (renderPass.IsPostProcessingPass)
            {
                _postProcessingRenderPasses.Add(renderPass);
            }
            else
            {
                _standardRenderPasses.Add(renderPass);
            }

            return renderPass;
        }
Esempio n. 13
0
        public IRenderPass AppendTransientRenderPass(IRenderPass renderPass)
        {
            if (renderPass.IsPostProcessingPass)
            {
                _transientPostProcessingRenderPasses.Add(renderPass);
            }
            else
            {
                _transientStandardRenderPasses.Add(renderPass);
            }

            return renderPass;
        }
 public DefaultRenderPipeline(
     IGraphicsBlit graphicsBlit,
     IRenderTargetBackBufferUtilities renderTargetBackBufferUtilities,
     IProfiler profiler,
     [FromGame] IEngineHook[] engineHooks)
 {
     _graphicsBlit = graphicsBlit;
     _renderTargetBackBufferUtilities = renderTargetBackBufferUtilities;
     _profiler = profiler;
     _engineHooks = engineHooks;
     _standardRenderPasses = new List<IRenderPass>();
     _postProcessingRenderPasses = new List<IRenderPass>();
     _transientStandardRenderPasses = new List<IRenderPass>();
     _transientPostProcessingRenderPasses = new List<IRenderPass>();
     _renderPass = null;
     _isFirstRenderPass = false;
 }
Esempio n. 15
0
 public DefaultRenderPipeline(
     IGraphicsBlit graphicsBlit,
     IRenderTargetBackBufferUtilities renderTargetBackBufferUtilities,
     IProfiler profiler,
     [FromGame] IEngineHook[] engineHooks)
 {
     _graphicsBlit = graphicsBlit;
     _renderTargetBackBufferUtilities = renderTargetBackBufferUtilities;
     _profiler                            = profiler;
     _engineHooks                         = engineHooks;
     _standardRenderPasses                = new List <IRenderPass>();
     _postProcessingRenderPasses          = new List <IRenderPass>();
     _transientStandardRenderPasses       = new List <IRenderPass>();
     _transientPostProcessingRenderPasses = new List <IRenderPass>();
     _renderPass                          = null;
     _isFirstRenderPass                   = false;
 }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            if (Viewport != null)
            {
                renderContext.GraphicsDevice.Viewport = Viewport.Value;
            }
            else
            {
                renderContext.GraphicsDevice.Viewport = new Viewport(
                    0,
                    0,
                    renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth,
                    renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight);
            }

            renderContext.SpriteBatch.Begin(TextureSortMode);
        }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass,
            RenderTarget2D postProcessingSource)
        {
            if (!Enabled)
            {
                return;
            }

            var x = 0;
            var y = 0;

            if (_console != null)
            {
                if (_console.State == ConsoleState.Open || _console.State == ConsoleState.OpenNoInput)
                {
                    y = 300;
                }
            }
            
            renderContext.SpriteBatch.Begin(SpriteSortMode.Immediate);
            
            foreach (var visualiser in Visualisers)
            {
                var height = visualiser.GetHeight(renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight);
                var rect = new Rectangle(
                    Position == ProfilerPosition.TopLeft ? 0 : (renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth - 300),
                    y,
                    300,
                    height);

                // Draw a background for the profiler.
                _renderUtilities.RenderRectangle(
                    renderContext,
                    rect,
                    new Color(0, 0, 0, 210),
                    true);

                // Ask the profiler to render it's content.
                visualiser.Render(gameContext, renderContext, rect);

                y += height;
            }

            renderContext.SpriteBatch.End();
        }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            if (EnabledLayers.Count == 0)
            {
                return;
            }

            _oldRasterizerState = renderContext.GraphicsDevice.RasterizerState;
            _oldDepthState = renderContext.GraphicsDevice.DepthStencilState;

            if (_debugRasterizerState == null)
            {
                _debugRasterizerState = new RasterizerState()
                {
                    CullMode = CullMode.None,
                    FillMode = FillMode.WireFrame,
                    DepthBias = _oldRasterizerState.DepthBias,
                    DepthClipEnable = true,
                    MultiSampleAntiAlias = false,
                    Name = "PhysicsDebugRasterizerState",
                    ScissorTestEnable = false,
                    SlopeScaleDepthBias = _oldRasterizerState.SlopeScaleDepthBias
                };
            }

            if (_debugDepthState == null)
            {
                _debugDepthState = new DepthStencilState()
                {
                    DepthBufferEnable = false,
                    DepthBufferWriteEnable = false
                };
            }

            renderContext.GraphicsDevice.RasterizerState = _debugRasterizerState;
            renderContext.GraphicsDevice.DepthStencilState = _debugDepthState;

            Lines.Clear();
            Triangles.Clear();
        }
Esempio n. 19
0
    public static void RunGame(EventExchange global, IContainer services, IRenderPass mainPass, string baseDir, CommandLineOptions commandLine)
    {
        RegisterComponents(global, services, mainPass, baseDir, commandLine);

        PerfTracker.StartupEvent("Running game");
        global.Raise(new SetSceneEvent(SceneId.Empty), null);

        if (commandLine.Commands != null)
        {
            foreach (var command in commandLine.Commands)
            {
                global.Raise(Event.Parse(command), null);
            }
        }
        else
        {
            global.Raise(new SetSceneEvent(SceneId.MainMenu), null);
        }

        global.Resolve <IEngine>().Run();
        // TODO: Ensure all sprite leases returned etc to weed out memory leaks
    }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            // Setup the default sprite effect.
            var vp = Viewport ?? renderContext.GraphicsDevice.Viewport;

            Matrix projection;

            // Normal 3D cameras look into the -z direction (z = 1 is in font of z = 0). The
            // sprite batch layer depth is the opposite (z = 0 is in front of z = 1).
            // --> We get the correct matrix with near plane 0 and far plane -1.
            Matrix.CreateOrthographicOffCenter(0, vp.Width, vp.Height, 0, 0, -1, out projection);

            // Some platforms require a half pixel offset to match DX.
#if !PLATFORM_WINDOWS
            projection.M41 += -0.5f * projection.M11;
            projection.M42 += -0.5f * projection.M22;
#endif
            
            renderContext.View = Matrix.Identity;
            renderContext.Projection = projection;
            renderContext.World = Matrix.Identity;
        }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            #if PLATFORM_WINDOWS
            if (!_viewportConfigured)
            {
                _viewport = new Viewport(
                    0,
                    0,
                    gameContext.Game.Window.ClientBounds.Width,
                    gameContext.Game.Window.ClientBounds.Height);
                _viewportConfigured = true;
            }
            #endif

            if (_viewportConfigured)
            {
                renderContext.GraphicsDevice.Viewport = this.Viewport;
            }

            renderContext.Is3DContext = false;

            renderContext.SpriteBatch.Begin(TextureSortMode);
        }
Esempio n. 22
0
 public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
 {
 }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass,
                                    RenderTarget2D postProcessingSource)
        {
            if (!Enabled)
            {
                return;
            }

            var x = 0;
            var y = 0;

            if (_console != null)
            {
                if (_console.State == ConsoleState.Open || _console.State == ConsoleState.OpenNoInput)
                {
                    y = 300;
                }
            }

            renderContext.SpriteBatch.Begin(SpriteSortMode.Immediate);

            foreach (var visualiser in Visualisers)
            {
                var height = visualiser.GetHeight(renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight);
                var rect   = new Rectangle(
                    Position == ProfilerPosition.TopLeft ? 0 : (renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth - 300),
                    y,
                    300,
                    height);

                // Draw a background for the profiler.
                _renderUtilities.RenderRectangle(
                    renderContext,
                    rect,
                    new Color(0, 0, 0, 210),
                    true);

                // Ask the profiler to render it's content.
                visualiser.Render(gameContext, renderContext, rect);

                y += height;
            }

            renderContext.SpriteBatch.End();
        }
Esempio n. 24
0
 public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
 {
 }
        private void SetupRenderPassViewport(IRenderContext renderContext, IRenderPass pass)
        {
            var renderPassWithViewport = pass as IRenderPassWithViewport;

            Viewport newViewport;
            if (renderPassWithViewport?.Viewport != null)
            {
                newViewport = renderPassWithViewport.Viewport.Value;
            }
            else
            {
                newViewport = new Viewport(
                    0,
                    0,
                    renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth,
                    renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight);
            }

            var currentViewport = renderContext.GraphicsDevice.Viewport;
            if (currentViewport.X != newViewport.X ||
                currentViewport.Y != newViewport.Y ||
                currentViewport.Width != newViewport.Width ||
                currentViewport.Height != newViewport.Height)
            {
                // The viewport is different, assign it to the GPU.
                renderContext.GraphicsDevice.Viewport = newViewport;
            }
        }
 public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass,
     RenderTarget2D postProcessingSource)
 {
     _console.Update(gameContext, ((ICoreGame)gameContext.Game).UpdateContext);
 }
Esempio n. 27
0
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            if (!_basicEffect.IsReady)
            {
                return;
            }

            _oldRasterizerState = renderContext.GraphicsDevice.RasterizerState;
            _oldDepthState      = renderContext.GraphicsDevice.DepthStencilState;

            if (_debugRasterizerState == null)
            {
                _debugRasterizerState = new RasterizerState()
                {
                    CullMode             = CullMode.None,
                    FillMode             = FillMode.WireFrame,
                    DepthBias            = _oldRasterizerState.DepthBias,
                    DepthClipEnable      = true,
                    MultiSampleAntiAlias = false,
                    Name = "InspectorRasterizerState",
                    ScissorTestEnable   = false,
                    SlopeScaleDepthBias = _oldRasterizerState.SlopeScaleDepthBias
                };
            }

            if (_debugDepthState == null)
            {
                _debugDepthState = new DepthStencilState()
                {
                    DepthBufferEnable      = false,
                    DepthBufferWriteEnable = false
                };
            }

            renderContext.GraphicsDevice.RasterizerState   = _debugRasterizerState;
            renderContext.GraphicsDevice.DepthStencilState = _debugDepthState;

            Lines.Clear();
            Triangles.Clear();
        }
Esempio n. 28
0
 public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
 {
     _graphicsBlit.Blit(renderContext, postProcessingSource, null, _effect);
 }
        public void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            try
            {
                renderContext.Render(gameContext);

                // NOTE: We MUST clear the depth buffer because OpenGL will not do it for us.
                renderContext.GraphicsDevice.Clear(
                    ClearOptions.DepthBuffer, 
                    Microsoft.Xna.Framework.Color.Transparent, 
                    renderContext.GraphicsDevice.Viewport.MaxDepth,
                    0);

                _primary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_primary, gameContext);
                _secondary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_secondary, gameContext);

                if (_primary == null || _secondary == null)
                {
                    // These are null if the window is minimized or invalid, in which case we don't
                    // render anything anyway.
                    return;
                }

                var standardRenderPasses = _standardRenderPasses.ToArray();
                var postProcessingRenderPasses = _postProcessingRenderPasses.ToArray();
                IRenderPass previousPass = null;
                IRenderPass nextPass = null;

                var entities = gameContext.World.GetEntitiesForWorld(gameContext.Hierarchy).ToArray();

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(_primary);
#endif

                for (var i = 0; i < standardRenderPasses.Length; i++)
                {
                    var pass = standardRenderPasses[i];
                    using (_profiler.Measure("r-" + pass.GetType().Name))
                    {
                        _isFirstRenderPass = previousPass == null;
                        _renderPass = pass;
                        SetupRenderPassViewport(renderContext, pass);
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                        previousPass = pass;
                        RenderPass(gameContext, renderContext, pass, entities);
                        if (i < standardRenderPasses.Length - 1)
                        {
                            nextPass = standardRenderPasses[i + 1];
                        }
                        else if (_transientStandardRenderPasses.Count > 0)
                        {
                            nextPass = _transientStandardRenderPasses[0];
                        }
                        else if (postProcessingRenderPasses.Length > 0)
                        {
                            nextPass = postProcessingRenderPasses[0];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);
                    }
                }

                var loop = 100;
                while (_transientStandardRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientStandardRenderPasses = _transientStandardRenderPasses.ToArray();
                    _transientStandardRenderPasses.Clear();

                    for (var i = 0; i < transientStandardRenderPasses.Length; i++)
                    {
                        var pass = transientStandardRenderPasses[i];
                        using (_profiler.Measure("r-" + pass.GetType().Name))
                        {
                            _isFirstRenderPass = previousPass == null;
                            _renderPass = pass;
                            SetupRenderPassViewport(renderContext, pass);
                            pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                            previousPass = pass;
                            RenderPass(gameContext, renderContext, pass, entities);
                            if (i < transientStandardRenderPasses.Length - 1)
                            {
                                nextPass = transientStandardRenderPasses[i + 1];
                            }
                            else if (_transientStandardRenderPasses.Count > 0)
                            {
                                nextPass = _transientStandardRenderPasses[0];
                            }
                            else if (postProcessingRenderPasses.Length > 0)
                            {
                                nextPass = postProcessingRenderPasses[0];
                            }
                            else if (_transientPostProcessingRenderPasses.Count > 0)
                            {
                                nextPass = _transientPostProcessingRenderPasses[0];
                            }
                            else
                            {
                                nextPass = null;
                            }
                            pass.EndRenderPass(gameContext, renderContext, nextPass);
                        }
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                        "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                        "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();
#endif

                if (postProcessingRenderPasses.Length == 0 && _transientPostProcessingRenderPasses.Count == 0)
                {
                    // Blit the primary render target to the backbuffer and return.
#if !DISABLE_PIPELINE_TARGETS
                    _graphicsBlit.Blit(renderContext, _primary);
#endif
                    return;
                }

                var currentSource = _primary;
                var currentDest = _secondary;

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(currentDest);
#endif

                for (var i = 0; i < postProcessingRenderPasses.Length; i++)
                {
                    var pass = postProcessingRenderPasses[i];
                    using (_profiler.Measure("r-" + pass.GetType().Name))
                    {
                        _isFirstRenderPass = previousPass == null;
                        _renderPass = pass;
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, currentSource);
                        previousPass = pass;
                        if (i < postProcessingRenderPasses.Length - 1)
                        {
                            nextPass = postProcessingRenderPasses[i + 1];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);

                        var temp = currentSource;
                        currentSource = currentDest;
                        currentDest = temp;

#if !DISABLE_PIPELINE_TARGETS
                        renderContext.PopRenderTarget();
                        renderContext.PushRenderTarget(currentDest);
#endif

                        // NOTE: This does not clear the new destination render target; it is expected that
                        // post-processing effects will fully overwrite the destination.
                    }
                }

                loop = 100;
                while (_transientPostProcessingRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientPostProcessingRenderPasses = _transientPostProcessingRenderPasses.ToArray();
                    _transientPostProcessingRenderPasses.Clear();

                    for (var i = 0; i < transientPostProcessingRenderPasses.Length; i++)
                    {
                        var pass = transientPostProcessingRenderPasses[i];
                        using (_profiler.Measure("r-" + pass.GetType().Name))
                        {
                            _isFirstRenderPass = previousPass == null;
                            _renderPass = pass;
                            pass.BeginRenderPass(gameContext, renderContext, previousPass, currentSource);
                            previousPass = pass;
                            if (i < transientPostProcessingRenderPasses.Length - 1)
                            {
                                nextPass = transientPostProcessingRenderPasses[i + 1];
                            }
                            else if (_transientPostProcessingRenderPasses.Count > 0)
                            {
                                nextPass = _transientPostProcessingRenderPasses[0];
                            }
                            else
                            {
                                nextPass = null;
                            }
                            pass.EndRenderPass(gameContext, renderContext, nextPass);

                            var temp = currentSource;
                            currentSource = currentDest;
                            currentDest = temp;

#if !DISABLE_PIPELINE_TARGETS
                            renderContext.PopRenderTarget();
                            renderContext.PushRenderTarget(currentDest);
#endif

                            // NOTE: This does not clear the new destination render target; it is expected that
                            // post-processing effects will fully overwrite the destination.
                        }
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                        "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                        "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();

                _graphicsBlit.Blit(renderContext, currentSource);
#endif
            }
            finally
            {
                _renderPass = null;
                _isFirstRenderPass = false;
            }
        }
Esempio n. 30
0
 public void RemoveFixedRenderPass(IRenderPass renderPass)
 {
     if (renderPass.IsPostProcessingPass)
     {
         _postProcessingRenderPasses.Remove(renderPass);
     }
     else
     {
         _standardRenderPasses.Remove(renderPass);
     }
 }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            var effect = GetEffect();

            if (effect != null)
            {
                _graphicsBlit.Blit(renderContext, postProcessingSource, null, effect);
            }
        }
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            if (!_invertEffect.IsReady)
            {
                return;
            }

            _graphicsBlit.Blit(renderContext, postProcessingSource, null, _invertEffect.Asset.Effect);
        }
Esempio n. 33
0
        public void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            try
            {
                renderContext.Render(gameContext);

                _primary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_primary, gameContext);
                _secondary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_secondary, gameContext);

                var standardRenderPasses = _standardRenderPasses.ToArray();
                var postProcessingRenderPasses = _postProcessingRenderPasses.ToArray();
                //IRenderPass[] transientStandardRenderPasses;
                //IRenderPass[] transientPostProcessingRenderPasses;
                IRenderPass previousPass = null;
                IRenderPass nextPass = null;

                var entities = gameContext.World.Entities.ToArray();

            #if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(_primary);
            #endif

                for (var i = 0; i < standardRenderPasses.Length; i++)
                {
                    var pass = standardRenderPasses[i];
                    _isFirstRenderPass = previousPass == null;
                    _renderPass = pass;
                    pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                    previousPass = pass;
                    RenderPass(gameContext, renderContext, entities);
                    if (i < standardRenderPasses.Length - 1)
                    {
                        nextPass = standardRenderPasses[i + 1];
                    }
                    else if (_transientStandardRenderPasses.Count > 0)
                    {
                        nextPass = _transientStandardRenderPasses[0];
                    }
                    else if (postProcessingRenderPasses.Length > 0)
                    {
                        nextPass = postProcessingRenderPasses[0];
                    }
                    else if (_transientPostProcessingRenderPasses.Count > 0)
                    {
                        nextPass = _transientPostProcessingRenderPasses[0];
                    }
                    else
                    {
                        nextPass = null;
                    }
                    pass.EndRenderPass(gameContext, renderContext, nextPass);
                }

                var loop = 100;
                while (_transientStandardRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientStandardRenderPasses = _transientStandardRenderPasses.ToArray();
                    _transientStandardRenderPasses.Clear();

                    for (var i = 0; i < transientStandardRenderPasses.Length; i++)
                    {
                        var pass = transientStandardRenderPasses[i];
                        _isFirstRenderPass = previousPass == null;
                        _renderPass = pass;
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                        previousPass = pass;
                        RenderPass(gameContext, renderContext, entities);
                        if (i < transientStandardRenderPasses.Length - 1)
                        {
                            nextPass = transientStandardRenderPasses[i + 1];
                        }
                        else if (_transientStandardRenderPasses.Count > 0)
                        {
                            nextPass = _transientStandardRenderPasses[0];
                        }
                        else if (postProcessingRenderPasses.Length > 0)
                        {
                            nextPass = postProcessingRenderPasses[0];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                        "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                        "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

            #if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();
            #endif

                if (postProcessingRenderPasses.Length == 0 && _transientPostProcessingRenderPasses.Count == 0)
                {
                    // Blit the primary render target to the backbuffer and return.
            #if !DISABLE_PIPELINE_TARGETS
                    _graphicsBlit.Blit(renderContext, _primary);
            #endif
                    return;
                }

                var currentSource = _primary;
                var currentDest = _secondary;

            #if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(currentDest);
            #endif

                for (var i = 0; i < postProcessingRenderPasses.Length; i++)
                {
                    var pass = postProcessingRenderPasses[i];
                    _isFirstRenderPass = previousPass == null;
                    _renderPass = pass;
                    pass.BeginRenderPass(gameContext, renderContext, previousPass, currentSource);
                    previousPass = pass;
                    if (i < postProcessingRenderPasses.Length - 1)
                    {
                        nextPass = postProcessingRenderPasses[i + 1];
                    }
                    else if (_transientPostProcessingRenderPasses.Count > 0)
                    {
                        nextPass = _transientPostProcessingRenderPasses[0];
                    }
                    else
                    {
                        nextPass = null;
                    }
                    pass.EndRenderPass(gameContext, renderContext, nextPass);

                    var temp = currentSource;
                    currentSource = currentDest;
                    currentDest = temp;

            #if !DISABLE_PIPELINE_TARGETS
                    renderContext.PopRenderTarget();
                    renderContext.PushRenderTarget(currentDest);
            #endif

                    // NOTE: This does not clear the new destination render target; it is expected that
                    // post-processing effects will fully overwrite the destination.
                }

                loop = 100;
                while (_transientPostProcessingRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientPostProcessingRenderPasses = _transientPostProcessingRenderPasses.ToArray();
                    _transientPostProcessingRenderPasses.Clear();

                    for (var i = 0; i < transientPostProcessingRenderPasses.Length; i++)
                    {
                        var pass = transientPostProcessingRenderPasses[i];
                        _isFirstRenderPass = previousPass == null;
                        _renderPass = pass;
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, currentSource);
                        previousPass = pass;
                        if (i < transientPostProcessingRenderPasses.Length - 1)
                        {
                            nextPass = transientPostProcessingRenderPasses[i + 1];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);

                        var temp = currentSource;
                        currentSource = currentDest;
                        currentDest = temp;

            #if !DISABLE_PIPELINE_TARGETS
                        renderContext.PopRenderTarget();
                        renderContext.PushRenderTarget(currentDest);
            #endif

                        // NOTE: This does not clear the new destination render target; it is expected that
                        // post-processing effects will fully overwrite the destination.
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                        "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                        "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

            #if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();

                _graphicsBlit.Blit(renderContext, currentSource);
            #endif
            }
            finally
            {
                _renderPass = null;
                _isFirstRenderPass = false;
            }
        }
 public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
 {
     renderContext.SpriteBatch.Begin(TextureSortMode);
 }
Esempio n. 35
0
        public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
        {
            if (!_basicEffect.IsReady)
            {
                return;
            }

            var world      = renderContext.World;
            var view       = renderContext.View;
            var projection = renderContext.Projection;

            renderContext.View       = View;
            renderContext.Projection = Projection;
            renderContext.World      = Matrix.Identity;

            _basicEffect.Asset.Effects["Color"].NativeEffect.Parameters["World"].SetValue(renderContext.World);
            _basicEffect.Asset.Effects["Color"].NativeEffect.Parameters["View"].SetValue(renderContext.View);
            _basicEffect.Asset.Effects["Color"].NativeEffect.Parameters["Projection"].SetValue(renderContext.Projection);

            foreach (var pass in _basicEffect.Asset.Effects["Color"].NativeEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                if (Lines.Count > 0)
                {
                    // Batch render all lines.
                    var lines = Lines.ToArray();
                    for (var i = 0; i < lines.Length; i += 1000)
                    {
                        renderContext.GraphicsDevice.DrawUserPrimitives(
                            PrimitiveType.LineList,
                            lines,
                            i,
                            lines.Length - i > 1000 ? 500 : (lines.Length - i) / 2);
                    }
                }

                if (Triangles.Count > 0)
                {
                    // Batch render all triangles.
                    var triangles = Triangles.ToArray();
                    for (var i = 0; i < triangles.Length; i += 1500)
                    {
                        renderContext.GraphicsDevice.DrawUserPrimitives(
                            PrimitiveType.TriangleList,
                            triangles,
                            i,
                            triangles.Length - i > 1500 ? 500 : (triangles.Length - i) / 3);
                    }
                }
            }

            renderContext.World      = world;
            renderContext.View       = view;
            renderContext.Projection = projection;

            renderContext.GraphicsDevice.RasterizerState   = _oldRasterizerState;
            renderContext.GraphicsDevice.DepthStencilState = _oldDepthState;
        }
 public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
 {
     renderContext.SpriteBatch.End();
 }
Esempio n. 37
0
 public FixedRenderPassEntity(IGraphicsFactory graphicsFactory)
 {
     _renderPass       = graphicsFactory.Create3DRenderPass();
     _someOnceOffField = true;
 }
 public TransientRenderPassEntity(IGraphicsFactory graphicsFactory)
 {
     _renderPass = graphicsFactory.CreateBlurPostProcessingRenderPass();
 }
        private void RenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass renderPass, IEntity[] entities)
        {
            if (!renderPass.SkipWorldRenderBelow)
            {
                gameContext.World.RenderBelow(gameContext, renderContext);
            }

            if (!renderPass.SkipEntityRender)
            {
                foreach (var entity in entities.OfType<IPrerenderableEntity>())
                {
                    entity.Prerender(gameContext, renderContext);
                }

                foreach (var entity in entities)
                {
                    entity.Render(gameContext, renderContext);
                }
            }

            if (!renderPass.SkipWorldRenderAbove)
            {
                gameContext.World.RenderAbove(gameContext, renderContext);
            }

            if (!renderPass.SkipEngineHookRender)
            {
                foreach (var hook in _engineHooks)
                {
                    hook.Render(gameContext, renderContext);
                }
            }
        }
 /// <summary>
 /// Append the specified render pass to the render pipeline
 /// for this frame only.  This is method that allows you to temporarily
 /// add additional render passes to a frame.
 /// <para>
 /// If all standard (non-post-processing) render passes have finished
 /// post-processing has begun and this method is given a standard render
 /// pass, it will have no effect.
 /// </para>
 /// <para>
 /// Render passes that were appended can not be removed with
 /// <see cref="RemoveFixedRenderPass"/>.
 /// </para>
 /// </summary>
 /// <returns>
 /// The render pass that was given to this function.  This return
 /// value is for convenience only, so that you may construct and add
 /// a render pass in a single statement, while obtaining a reference to
 /// it if you need to modify it's value.  The render pass is not
 /// modified by this function.
 /// </returns>
 /// <param name="renderPass">The render pass to add.</param>
 public IRenderPass AppendTransientRenderPass(IRenderPass renderPass)
 {
     return(_renderPipeline.AppendTransientRenderPass(renderPass));
 }
        public void EndRenderPass(
            IGameContext gameContext, 
            IRenderContext renderContext, 
            IRenderPass nextPass)
        {
            _renderBatcher.FlushRequests(gameContext, renderContext);
            
            renderContext.PopRenderTarget();

            renderContext.GraphicsDevice.DepthStencilState = _previousDepthStencilState;
            renderContext.GraphicsDevice.RasterizerState = _previousRasterizerState;
            renderContext.GraphicsDevice.BlendState = _previousBlendState;
            
            renderContext.PushRenderTarget(_diffuseLightRenderTarget);
            renderContext.GraphicsDevice.Clear(Color.Transparent);
            renderContext.PopRenderTarget();

            renderContext.PushRenderTarget(_specularLightRenderTarget);
            renderContext.GraphicsDevice.Clear(Color.Transparent);
            renderContext.PopRenderTarget();

            var lightContext = new DefaultLightContext(
                _colorRenderTarget,
                _normalRenderTarget,
                _depthRenderTarget,
                _specularRenderTarget,
                _diffuseLightRenderTarget,
                _specularLightRenderTarget,
                _lightBlendState,
                _rasterizerStateCullNone,
                _rasterizerStateCullClockwiseFace,
                _rasterizerStateCullCounterClockwiseFace,
                new Vector2(
                    0.5f/renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth,
                    0.5f/renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight));

            var lights = new List<ILight>();

            foreach (var l in _hierarchy.Lookup(gameContext.World).Children.Select(x => x.UntypedValue).OfType<IHasLights>())
            {
                lights.AddRange(l.GetLights());
            }

            renderContext.GraphicsDevice.BlendState = _lightBlendState;
            renderContext.GraphicsDevice.DepthStencilState = _lightDepthStencilState;
            
            foreach (var light in lights)
            {
                light.Render(gameContext, renderContext, lightContext);
            }

            renderContext.GraphicsDevice.BlendState = _previousBlendState;
            renderContext.GraphicsDevice.DepthStencilState = _previousDepthStencilState;

            if (DebugGBuffer)
            {
                // Render the G buffer into 4 quadrants on the current render target.
                renderContext.GraphicsDevice.Clear(Color.Purple);
                _graphicsBlit.Blit(
                    renderContext,
                    _colorRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0, 0),
                    new Vector2(0.33f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _normalRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.33f, 0),
                    new Vector2(0.34f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _depthRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.67f, 0f),
                    new Vector2(0.33f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _specularRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.0f, 0.5f),
                    new Vector2(0.33f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _diffuseLightRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.33f, 0.5f),
                    new Vector2(0.34f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _specularLightRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.67f, 0.5f),
                    new Vector2(0.33f, 0.5f));
            }
            else
            {
                var parameterSet = _gbufferCombineEffect.Effect.CreateParameterSet();
                parameterSet["Color"]?.SetValue(_colorRenderTarget);
                parameterSet["DiffuseLight"]?.SetValue(_diffuseLightRenderTarget);
                parameterSet["SpecularLight"]?.SetValue(_specularLightRenderTarget);
                parameterSet["AmbientLight"]?.SetValue(new Vector3(0.2f, 0.2f, 0.2f));

                _graphicsBlit.Blit(
                    renderContext,
                    null,
                    null,
                    _gbufferCombineEffect.Effect,
                    parameterSet,
                    BlendState.Opaque);
            }
        }
Esempio n. 42
0
    static void Main(string[] args)
    {
#if DEBUG
        PerfTracker.IsTracing = true;
#endif
        PerfTracker.StartupEvent("Entered main");
        AssetSystem.LoadEvents();
        PerfTracker.StartupEvent("Built event parsers");

        var commandLine = new CommandLineOptions(args);
        if (commandLine.Mode == ExecutionMode.Exit)
        {
            return;
        }

        PerfTracker.StartupEvent($"Running as {commandLine.Mode}");
        var disk     = new FileSystem();
        var jsonUtil = new FormatJsonUtil();

        var baseDir = ConfigUtil.FindBasePath(disk);
        if (baseDir == null)
        {
            throw new InvalidOperationException("No base directory could be found.");
        }

        PerfTracker.StartupEvent($"Found base directory {baseDir}");

        if (commandLine.Mode == ExecutionMode.ConvertAssets)
        {
            using var converter = new AssetConverter(
                      AssetMapping.Global,
                      disk,
                      jsonUtil,
                      commandLine.ConvertFrom,
                      commandLine.ConvertTo);

            converter.Convert(
                commandLine.DumpIds,
                commandLine.DumpAssetTypes,
                commandLine.ConvertFilePattern);

            return;
        }

        var(exchange, services) = AssetSystem.SetupAsync(baseDir, AssetMapping.Global, disk, jsonUtil).Result;
        IRenderPass mainPass = null;
        if (commandLine.NeedsEngine)
        {
            mainPass = BuildEngine(commandLine, exchange);
        }

        services.Add(new StdioConsoleReader());

        var assets = exchange.Resolve <IAssetManager>();
        AutodetectLanguage(exchange, assets);

        switch (commandLine.Mode) // ConvertAssets handled above as it requires a specialised asset system setup
        {
        case ExecutionMode.Game: Albion.RunGame(exchange, services, mainPass, baseDir, commandLine); break;

        case ExecutionMode.BakeIsometric: IsometricTest.Run(exchange, commandLine); break;

        case ExecutionMode.DumpData:
            PerfTracker.BeginFrame();     // Don't need to show verbose startup logging while dumping
            var tf = new TextFormatter();
            exchange.Attach(tf);
            var parsedIds = commandLine.DumpIds?.Select(AssetId.Parse).ToArray();

            if ((commandLine.DumpFormats & DumpFormats.Json) != 0)
            {
                var dumper = new DumpJson();
                exchange.Attach(dumper);
                dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds);
                dumper.Remove();
            }

            if ((commandLine.DumpFormats & DumpFormats.Text) != 0)
            {
                var dumper = new DumpText();
                exchange.Attach(dumper);
                dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds);
                dumper.Remove();
            }

            if ((commandLine.DumpFormats & DumpFormats.Png) != 0)
            {
                var dumper = new DumpGraphics(commandLine.DumpFormats);
                exchange.Attach(dumper);
                dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds);
                dumper.Remove();
            }

            if ((commandLine.DumpFormats & DumpFormats.Annotated) != 0)
            {
                var dumper = new DumpAnnotated();
                exchange.Attach(dumper);
                dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds);
                dumper.Remove();
            }

            //if ((commandLine.DumpFormats & DumpFormats.Tiled) != 0)
            //    DumpTiled.Dump(baseDir, assets, commandLine.DumpAssetTypes, parsedIds);
            break;

        case ExecutionMode.Exit: break;
        }

        Console.WriteLine("Exiting");
        exchange.Dispose();
    }
        public void BeginRenderPass(
            IGameContext gameContext,
            IRenderContext renderContext, 
            IRenderPass previousPass,      
            RenderTarget2D postProcessingSource)
        {
            _colorRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_colorRenderTarget, gameContext, SurfaceFormat.Color, DepthFormat.Depth24, null);
            _normalRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_normalRenderTarget, gameContext, SurfaceFormat.Color, DepthFormat.None, null);
            _depthRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_depthRenderTarget, gameContext, SurfaceFormat.Single, DepthFormat.None, null);
            _specularRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_specularRenderTarget, gameContext, SurfaceFormat.Color, DepthFormat.None, null);
            _diffuseLightRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_diffuseLightRenderTarget, gameContext, null, DepthFormat.None, null);
            _specularLightRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_specularLightRenderTarget, gameContext, null, DepthFormat.None, null);

            if (_rasterizerStateCullNone == null)
            {
                _rasterizerStateCullNone = new RasterizerState();
                _rasterizerStateCullNone.CullMode = CullMode.None;
                _rasterizerStateCullNone.FillMode = FillMode.Solid;
                _rasterizerStateCullNone.DepthBias = 0;
                _rasterizerStateCullNone.MultiSampleAntiAlias = true;
                _rasterizerStateCullNone.ScissorTestEnable = false;
                _rasterizerStateCullNone.SlopeScaleDepthBias = 0;
                _rasterizerStateCullNone.DepthClipEnable = true;
            }

            if (_rasterizerStateCullClockwiseFace == null)
            {
                _rasterizerStateCullClockwiseFace = new RasterizerState();
                _rasterizerStateCullClockwiseFace.CullMode = CullMode.CullClockwiseFace;
                _rasterizerStateCullClockwiseFace.FillMode = FillMode.Solid;
                _rasterizerStateCullClockwiseFace.DepthBias = 0;
                _rasterizerStateCullClockwiseFace.MultiSampleAntiAlias = true;
                _rasterizerStateCullClockwiseFace.ScissorTestEnable = false;
                _rasterizerStateCullClockwiseFace.SlopeScaleDepthBias = 0;
                _rasterizerStateCullClockwiseFace.DepthClipEnable = true;
            }

            if (_rasterizerStateCullCounterClockwiseFace == null)
            {
                _rasterizerStateCullCounterClockwiseFace = new RasterizerState();
                _rasterizerStateCullCounterClockwiseFace.CullMode = CullMode.CullCounterClockwiseFace;
                _rasterizerStateCullCounterClockwiseFace.FillMode = FillMode.Solid;
                _rasterizerStateCullCounterClockwiseFace.DepthBias = 0;
                _rasterizerStateCullCounterClockwiseFace.MultiSampleAntiAlias = true;
                _rasterizerStateCullCounterClockwiseFace.ScissorTestEnable = false;
                _rasterizerStateCullCounterClockwiseFace.SlopeScaleDepthBias = 0;
                _rasterizerStateCullCounterClockwiseFace.DepthClipEnable = true;
            }

            if (_depthStencilState == null)
            {
                _depthStencilState = DepthStencilState.Default;
            }

            if (_lightDepthStencilState == null)
            {
                _lightDepthStencilState = DepthStencilState.None;
            }

            if (_blendState == null)
            {
                _blendState = BlendState.Opaque;
            }

            if (_lightBlendState == null)
            {
                _lightBlendState = BlendState.AlphaBlend;
            }

            renderContext.PushRenderTarget(
                _colorRenderTarget,
                _normalRenderTarget,
                _depthRenderTarget,
                _specularRenderTarget);

            // Clear the geometry buffer before moving into main rendering.
            _graphicsBlit.Blit(
                renderContext,
                null,
                null,
                _gbufferClearEffect.Effect);

            _previousDepthStencilState = renderContext.GraphicsDevice.DepthStencilState;
            _previousRasterizerState = renderContext.GraphicsDevice.RasterizerState;
            _previousBlendState = renderContext.GraphicsDevice.BlendState;

            renderContext.GraphicsDevice.DepthStencilState = _depthStencilState;
            renderContext.GraphicsDevice.RasterizerState = _rasterizerStateCullCounterClockwiseFace;
            renderContext.GraphicsDevice.BlendState = _blendState;
        }
 public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
 {
     renderContext.SpriteBatch.Begin();
     _console.Render(gameContext, renderContext);
     renderContext.SpriteBatch.End();
 }
Esempio n. 45
0
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
        {
            _interlacedBatchingDepthProvider.Reset();

            // Setup the default sprite effect.
            var vp = Viewport ?? renderContext.GraphicsDevice.Viewport;

            Matrix projection;

            // Normal 3D cameras look into the -z direction (z = 1 is in font of z = 0). The
            // sprite batch layer depth is the opposite (z = 0 is in front of z = 1).
            // --> We get the correct matrix with near plane 0 and far plane -1.
            Matrix.CreateOrthographicOffCenter(0, vp.Width, vp.Height, 0, 0, -1, out projection);

            // Some platforms require a half pixel offset to match DX.
#if !PLATFORM_WINDOWS
            projection.M41 += -0.5f * projection.M11;
            projection.M42 += -0.5f * projection.M22;
#endif

            renderContext.View       = Matrix.Identity;
            renderContext.Projection = projection;
            renderContext.World      = Matrix.Identity;
        }
 public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
 {
 }
Esempio n. 47
0
        public void BeginRenderPass(
            IGameContext gameContext,
            IRenderContext renderContext,
            IRenderPass previousPass,
            RenderTarget2D postProcessingSource)
        {
            _colorRenderTarget         = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_colorRenderTarget, gameContext, SurfaceFormat.Color, DepthFormat.Depth24, null);
            _normalRenderTarget        = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_normalRenderTarget, gameContext, SurfaceFormat.Color, DepthFormat.None, null);
            _depthRenderTarget         = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_depthRenderTarget, gameContext, SurfaceFormat.Single, DepthFormat.None, null);
            _specularRenderTarget      = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_specularRenderTarget, gameContext, SurfaceFormat.Color, DepthFormat.None, null);
            _diffuseLightRenderTarget  = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_diffuseLightRenderTarget, gameContext, null, DepthFormat.None, null);
            _specularLightRenderTarget = _renderTargetBackBufferUtilities.UpdateCustomRenderTarget(_specularLightRenderTarget, gameContext, null, DepthFormat.None, null);

            if (_rasterizerStateCullNone == null)
            {
                _rasterizerStateCullNone                      = new RasterizerState();
                _rasterizerStateCullNone.CullMode             = CullMode.None;
                _rasterizerStateCullNone.FillMode             = FillMode.Solid;
                _rasterizerStateCullNone.DepthBias            = 0;
                _rasterizerStateCullNone.MultiSampleAntiAlias = true;
                _rasterizerStateCullNone.ScissorTestEnable    = false;
                _rasterizerStateCullNone.SlopeScaleDepthBias  = 0;
                _rasterizerStateCullNone.DepthClipEnable      = true;
            }

            if (_rasterizerStateCullClockwiseFace == null)
            {
                _rasterizerStateCullClockwiseFace                      = new RasterizerState();
                _rasterizerStateCullClockwiseFace.CullMode             = CullMode.CullClockwiseFace;
                _rasterizerStateCullClockwiseFace.FillMode             = FillMode.Solid;
                _rasterizerStateCullClockwiseFace.DepthBias            = 0;
                _rasterizerStateCullClockwiseFace.MultiSampleAntiAlias = true;
                _rasterizerStateCullClockwiseFace.ScissorTestEnable    = false;
                _rasterizerStateCullClockwiseFace.SlopeScaleDepthBias  = 0;
                _rasterizerStateCullClockwiseFace.DepthClipEnable      = true;
            }

            if (_rasterizerStateCullCounterClockwiseFace == null)
            {
                _rasterizerStateCullCounterClockwiseFace                      = new RasterizerState();
                _rasterizerStateCullCounterClockwiseFace.CullMode             = CullMode.CullCounterClockwiseFace;
                _rasterizerStateCullCounterClockwiseFace.FillMode             = FillMode.Solid;
                _rasterizerStateCullCounterClockwiseFace.DepthBias            = 0;
                _rasterizerStateCullCounterClockwiseFace.MultiSampleAntiAlias = true;
                _rasterizerStateCullCounterClockwiseFace.ScissorTestEnable    = false;
                _rasterizerStateCullCounterClockwiseFace.SlopeScaleDepthBias  = 0;
                _rasterizerStateCullCounterClockwiseFace.DepthClipEnable      = true;
            }

            if (_depthStencilState == null)
            {
                _depthStencilState = DepthStencilState.Default;
            }

            if (_lightDepthStencilState == null)
            {
                _lightDepthStencilState = DepthStencilState.None;
            }

            if (_blendState == null)
            {
                _blendState = BlendState.Opaque;
            }

            if (_lightBlendState == null)
            {
                _lightBlendState = BlendState.AlphaBlend;
            }

            renderContext.PushRenderTarget(
                _colorRenderTarget,
                _normalRenderTarget,
                _depthRenderTarget,
                _specularRenderTarget);

            if (ClearDepthBuffer || ClearTarget)
            {
                var target = ClearDepthBuffer ? ClearOptions.DepthBuffer : ClearOptions.Target;
                if (ClearDepthBuffer && ClearTarget)
                {
                    target = ClearOptions.DepthBuffer | ClearOptions.Target;
                }
                renderContext.GraphicsDevice.Clear(
                    target,
                    Microsoft.Xna.Framework.Color.Transparent,
                    renderContext.GraphicsDevice.Viewport.MaxDepth,
                    0);
            }

            // Clear the geometry buffer before moving into main rendering.
            _graphicsBlit.Blit(
                renderContext,
                null,
                null,
                _gbufferClearEffect.Effect);

            _previousDepthStencilState = renderContext.GraphicsDevice.DepthStencilState;
            _previousRasterizerState   = renderContext.GraphicsDevice.RasterizerState;
            _previousBlendState        = renderContext.GraphicsDevice.BlendState;

            renderContext.GraphicsDevice.DepthStencilState = _depthStencilState;
            renderContext.GraphicsDevice.RasterizerState   = _rasterizerStateCullCounterClockwiseFace;
            renderContext.GraphicsDevice.BlendState        = _blendState;
        }
Esempio n. 48
0
        public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass,
                                    RenderTarget2D postProcessingSource)
        {
            if (RenderPipelineStateAvailable != null)
            {
                RenderPipelineStateAvailable(postProcessingSource);
            }

            // Blit to the output.
            _graphicsBlit.Blit(renderContext, postProcessingSource);
        }
Esempio n. 49
0
        public void EndRenderPass(
            IGameContext gameContext,
            IRenderContext renderContext,
            IRenderPass nextPass)
        {
            _renderBatcher.FlushRequests(gameContext, renderContext);

            renderContext.PopRenderTarget();

            renderContext.GraphicsDevice.DepthStencilState = _previousDepthStencilState;
            renderContext.GraphicsDevice.RasterizerState   = _previousRasterizerState;
            renderContext.GraphicsDevice.BlendState        = _previousBlendState;

            renderContext.PushRenderTarget(_diffuseLightRenderTarget);
            renderContext.GraphicsDevice.Clear(Color.Transparent);
            renderContext.PopRenderTarget();

            renderContext.PushRenderTarget(_specularLightRenderTarget);
            renderContext.GraphicsDevice.Clear(Color.Transparent);
            renderContext.PopRenderTarget();

            var lightContext = new DefaultLightContext(
                _colorRenderTarget,
                _normalRenderTarget,
                _depthRenderTarget,
                _specularRenderTarget,
                _diffuseLightRenderTarget,
                _specularLightRenderTarget,
                _lightBlendState,
                _rasterizerStateCullNone,
                _rasterizerStateCullClockwiseFace,
                _rasterizerStateCullCounterClockwiseFace,
                new Vector2(
                    0.5f / renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth,
                    0.5f / renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight));

            var lights = new List <ILight>();

            if (gameContext.World != null)
            {
                foreach (var l in _hierarchy.Lookup(gameContext.World).Children.Select(x => x.UntypedValue).OfType <IHasLights>())
                {
                    lights.AddRange(l.GetLights());
                }
            }

            renderContext.GraphicsDevice.BlendState        = _lightBlendState;
            renderContext.GraphicsDevice.DepthStencilState = _lightDepthStencilState;

            foreach (var light in lights)
            {
                light.Render(gameContext, renderContext, lightContext);
            }

            renderContext.GraphicsDevice.BlendState        = _previousBlendState;
            renderContext.GraphicsDevice.DepthStencilState = _previousDepthStencilState;

            if (DebugGBuffer)
            {
                // Render the G buffer into 4 quadrants on the current render target.
                renderContext.GraphicsDevice.Clear(Color.Purple);
                _graphicsBlit.Blit(
                    renderContext,
                    _colorRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0, 0),
                    new Vector2(0.33f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _normalRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.33f, 0),
                    new Vector2(0.34f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _depthRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.67f, 0f),
                    new Vector2(0.33f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _specularRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.0f, 0.5f),
                    new Vector2(0.33f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _diffuseLightRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.33f, 0.5f),
                    new Vector2(0.34f, 0.5f));
                _graphicsBlit.Blit(
                    renderContext,
                    _specularLightRenderTarget,
                    null,
                    null,
                    null,
                    null,
                    new Vector2(0.67f, 0.5f),
                    new Vector2(0.33f, 0.5f));
            }
            else
            {
                var parameterSet = _gbufferCombineEffect.Effect.CreateParameterSet();
                parameterSet["Color"]?.SetValue(_colorRenderTarget);
                parameterSet["DiffuseLight"]?.SetValue(_diffuseLightRenderTarget);
                parameterSet["SpecularLight"]?.SetValue(_specularLightRenderTarget);
                parameterSet["AmbientLight"]?.SetValue(new Vector3(0.2f, 0.2f, 0.2f));

                _graphicsBlit.Blit(
                    renderContext,
                    null,
                    null,
                    _gbufferCombineEffect.Effect,
                    parameterSet,
                    GBufferBlendState);
            }
        }
Esempio n. 50
0
 public TransientRenderPassEntity(IGraphicsFactory graphicsFactory)
 {
     _renderPass = graphicsFactory.CreateBlurPostProcessingRenderPass();
 }
 public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
 {
     renderContext.Is3DContext = false;
 }
 public void BeginRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass previousPass, RenderTarget2D postProcessingSource)
 {
     _graphicsBlit.Blit(renderContext, postProcessingSource, null, _invertEffect);
 }
 /// <summary>
 /// Adds the specified render pass to the render pipeline
 /// permanently.  This render pass will take effect after the
 /// start of the next frame.
 /// </summary>
 /// <returns>
 /// The render pass that was given to this function.  This return
 /// value is for convenience only, so that you may construct and add
 /// a render pass in a single statement, while obtaining a reference to
 /// it if you need to modify it's values or call <see cref="RemoveFixedRenderPass"/>
 /// later.  The render pass is not modified by this function.
 /// </returns>
 /// <param name="renderPass">The render pass to add.</param>
 public IRenderPass AddFixedRenderPass(IRenderPass renderPass)
 {
     return(_renderPipeline.AddFixedRenderPass(renderPass));
 }
Esempio n. 54
0
        private void RenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass renderPass, IEntity[] entities)
        {
            if (!renderPass.SkipWorldRenderBelow)
            {
                gameContext.World.RenderBelow(gameContext, renderContext);
            }

            if (!renderPass.SkipEntityRender)
            {
                foreach (var entity in entities.OfType <IPrerenderableEntity>())
                {
                    entity.Prerender(gameContext, renderContext);
                }

                foreach (var entity in entities)
                {
                    entity.Render(gameContext, renderContext);
                }
            }

            if (!renderPass.SkipWorldRenderAbove)
            {
                gameContext.World.RenderAbove(gameContext, renderContext);
            }

            if (!renderPass.SkipEngineHookRender)
            {
                foreach (var hook in _engineHooks)
                {
                    hook.Render(gameContext, renderContext);
                }
            }
        }
 /// <summary>
 /// Removes the specified render pass from the render pipeline.
 /// </summary>
 /// <param name="renderPass">The render pass to remove.</param>
 public void RemoveFixedRenderPass(IRenderPass renderPass)
 {
     _renderPipeline.RemoveFixedRenderPass(renderPass);
 }
Esempio n. 56
0
        public void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            try
            {
                renderContext.Render(gameContext);

                // NOTE: We MUST clear the depth buffer because OpenGL will not do it for us.
                renderContext.GraphicsDevice.Clear(
                    ClearOptions.DepthBuffer,
                    Microsoft.Xna.Framework.Color.Transparent,
                    renderContext.GraphicsDevice.Viewport.MaxDepth,
                    0);

                _primary   = _renderTargetBackBufferUtilities.UpdateRenderTarget(_primary, gameContext);
                _secondary = _renderTargetBackBufferUtilities.UpdateRenderTarget(_secondary, gameContext);

                if (_primary == null || _secondary == null)
                {
                    // These are null if the window is minimized or invalid, in which case we don't
                    // render anything anyway.
                    return;
                }

                var         standardRenderPasses       = _standardRenderPasses.ToArray();
                var         postProcessingRenderPasses = _postProcessingRenderPasses.ToArray();
                IRenderPass previousPass = null;
                IRenderPass nextPass     = null;

                var entities = gameContext.World.GetEntitiesForWorld(gameContext.Hierarchy).ToArray();

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(_primary);
#endif

                for (var i = 0; i < standardRenderPasses.Length; i++)
                {
                    var pass = standardRenderPasses[i];
                    using (_profiler.Measure("r-" + pass.GetType().Name))
                    {
                        _isFirstRenderPass = previousPass == null;
                        _renderPass        = pass;
                        SetupRenderPassViewport(renderContext, pass);
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                        previousPass = pass;
                        RenderPass(gameContext, renderContext, pass, entities);
                        if (i < standardRenderPasses.Length - 1)
                        {
                            nextPass = standardRenderPasses[i + 1];
                        }
                        else if (_transientStandardRenderPasses.Count > 0)
                        {
                            nextPass = _transientStandardRenderPasses[0];
                        }
                        else if (postProcessingRenderPasses.Length > 0)
                        {
                            nextPass = postProcessingRenderPasses[0];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);
                    }
                }

                var loop = 100;
                while (_transientStandardRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientStandardRenderPasses = _transientStandardRenderPasses.ToArray();
                    _transientStandardRenderPasses.Clear();

                    for (var i = 0; i < transientStandardRenderPasses.Length; i++)
                    {
                        var pass = transientStandardRenderPasses[i];
                        using (_profiler.Measure("r-" + pass.GetType().Name))
                        {
                            _isFirstRenderPass = previousPass == null;
                            _renderPass        = pass;
                            SetupRenderPassViewport(renderContext, pass);
                            pass.BeginRenderPass(gameContext, renderContext, previousPass, null);
                            previousPass = pass;
                            RenderPass(gameContext, renderContext, pass, entities);
                            if (i < transientStandardRenderPasses.Length - 1)
                            {
                                nextPass = transientStandardRenderPasses[i + 1];
                            }
                            else if (_transientStandardRenderPasses.Count > 0)
                            {
                                nextPass = _transientStandardRenderPasses[0];
                            }
                            else if (postProcessingRenderPasses.Length > 0)
                            {
                                nextPass = postProcessingRenderPasses[0];
                            }
                            else if (_transientPostProcessingRenderPasses.Count > 0)
                            {
                                nextPass = _transientPostProcessingRenderPasses[0];
                            }
                            else
                            {
                                nextPass = null;
                            }
                            pass.EndRenderPass(gameContext, renderContext, nextPass);
                        }
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                              "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                              "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();
#endif

                if (postProcessingRenderPasses.Length == 0 && _transientPostProcessingRenderPasses.Count == 0)
                {
                    // Blit the primary render target to the backbuffer and return.
#if !DISABLE_PIPELINE_TARGETS
                    _graphicsBlit.Blit(renderContext, _primary);
#endif
                    return;
                }

                var currentSource = _primary;
                var currentDest   = _secondary;

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PushRenderTarget(currentDest);
#endif

                for (var i = 0; i < postProcessingRenderPasses.Length; i++)
                {
                    var pass = postProcessingRenderPasses[i];
                    using (_profiler.Measure("r-" + pass.GetType().Name))
                    {
                        _isFirstRenderPass = previousPass == null;
                        _renderPass        = pass;
                        pass.BeginRenderPass(gameContext, renderContext, previousPass, currentSource);
                        previousPass = pass;
                        if (i < postProcessingRenderPasses.Length - 1)
                        {
                            nextPass = postProcessingRenderPasses[i + 1];
                        }
                        else if (_transientPostProcessingRenderPasses.Count > 0)
                        {
                            nextPass = _transientPostProcessingRenderPasses[0];
                        }
                        else
                        {
                            nextPass = null;
                        }
                        pass.EndRenderPass(gameContext, renderContext, nextPass);

                        var temp = currentSource;
                        currentSource = currentDest;
                        currentDest   = temp;

#if !DISABLE_PIPELINE_TARGETS
                        renderContext.PopRenderTarget();
                        renderContext.PushRenderTarget(currentDest);
#endif

                        // NOTE: This does not clear the new destination render target; it is expected that
                        // post-processing effects will fully overwrite the destination.
                    }
                }

                loop = 100;
                while (_transientPostProcessingRenderPasses.Count > 0 && loop-- >= 0)
                {
                    var transientPostProcessingRenderPasses = _transientPostProcessingRenderPasses.ToArray();
                    _transientPostProcessingRenderPasses.Clear();

                    for (var i = 0; i < transientPostProcessingRenderPasses.Length; i++)
                    {
                        var pass = transientPostProcessingRenderPasses[i];
                        using (_profiler.Measure("r-" + pass.GetType().Name))
                        {
                            _isFirstRenderPass = previousPass == null;
                            _renderPass        = pass;
                            pass.BeginRenderPass(gameContext, renderContext, previousPass, currentSource);
                            previousPass = pass;
                            if (i < transientPostProcessingRenderPasses.Length - 1)
                            {
                                nextPass = transientPostProcessingRenderPasses[i + 1];
                            }
                            else if (_transientPostProcessingRenderPasses.Count > 0)
                            {
                                nextPass = _transientPostProcessingRenderPasses[0];
                            }
                            else
                            {
                                nextPass = null;
                            }
                            pass.EndRenderPass(gameContext, renderContext, nextPass);

                            var temp = currentSource;
                            currentSource = currentDest;
                            currentDest   = temp;

#if !DISABLE_PIPELINE_TARGETS
                            renderContext.PopRenderTarget();
                            renderContext.PushRenderTarget(currentDest);
#endif

                            // NOTE: This does not clear the new destination render target; it is expected that
                            // post-processing effects will fully overwrite the destination.
                        }
                    }
                }
                if (loop < 0)
                {
                    throw new InvalidOperationException(
                              "Exceeded the number of AppendTransientRenderPass iterations (100).  Ensure you " +
                              "are not unconditionally calling AppendTransientRenderPass within another render pass.");
                }

#if !DISABLE_PIPELINE_TARGETS
                renderContext.PopRenderTarget();

                _graphicsBlit.Blit(renderContext, currentSource);
#endif
            }
            finally
            {
                _renderPass        = null;
                _isFirstRenderPass = false;
            }
        }
 public void EndRenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass nextPass)
 {
     renderContext.SpriteBatch.End();
 }