public void Render(CommandList commandList, SizeF outputSize) { if (FadeType == CameraFadeType.NotFading) { return; } commandList.PushDebugGroup("Camera fade"); _drawingContext.Begin( commandList, _game.AssetStore.LoadContext.StandardGraphicsResources.LinearClampSampler, outputSize); switch (FadeType) { case CameraFadeType.AdditiveBlendToWhite: _drawingContext.FillRectangle( new RectangleF(Vector2.Zero, outputSize), new ColorRgbaF(CurrentValue, CurrentValue, CurrentValue, 1)); break; } _drawingContext.End(); commandList.PopDebugGroup(); }
internal void SetRenderTarget(RenderTarget renderTarget) { if (renderTarget != null) { _commandList.Begin(); _commandList.SetFramebuffer(renderTarget.Framebuffer); _commandList.ClearColorTarget(0, new RgbaFloat(0, 0, 0, 0)); _clipMaskDrawingContext.Begin( _commandList, _graphicsLoadContext.StandardGraphicsResources.LinearClampSampler, new SizeF(renderTarget.ColorTarget.Width, renderTarget.ColorTarget.Height)); _activeDrawingContext = _clipMaskDrawingContext; } else { _clipMaskDrawingContext.End(); _commandList.End(); _contentManager.GraphicsDevice.SubmitCommands(_commandList); _activeDrawingContext = _drawingContext; } }
public void Execute(RenderContext context) { RenderedObjectsOpaque = 0; RenderedObjectsTransparent = 0; EnsureIntermediateFramebuffer(context.GraphicsDevice, context.RenderTarget); _renderList.Clear(); context.Scene3D?.BuildRenderList( _renderList, context.Scene3D.Camera, context.GameTime); BuildingRenderList?.Invoke(this, new BuildingRenderListEventArgs( _renderList, context.Scene3D?.Camera, context.GameTime)); _commandList.Begin(); if (context.Scene3D != null) { _commandList.PushDebugGroup("3D Scene"); Render3DScene(_commandList, context.Scene3D, context); _commandList.PopDebugGroup(); } else { _commandList.SetFramebuffer(_intermediateFramebuffer); _commandList.ClearColorTarget(0, ClearColor); } // GUI and camera-dependent 2D elements { _commandList.PushDebugGroup("2D Scene"); _drawingContext.Begin( _commandList, context.ContentManager.LinearClampSampler, new SizeF(context.RenderTarget.Width, context.RenderTarget.Height)); context.Scene3D?.Render(_drawingContext); context.Scene2D?.Render(_drawingContext); Rendering2D?.Invoke(this, new Rendering2DEventArgs(_drawingContext)); _drawingContext.End(); _commandList.PopDebugGroup(); } _commandList.End(); context.GraphicsDevice.SubmitCommands(_commandList); _textureCopier.Execute( _intermediateTexture, context.RenderTarget); }
public void Execute(RenderContext context) { EnsureIntermediateFramebuffer(context.GraphicsDevice, context.RenderTarget); _renderList.Clear(); context.Scene?.BuildRenderList(_renderList, context.Camera); foreach (var system in context.Game.GameSystems) { system.BuildRenderList(_renderList); } context.Game.RaiseBuildingRenderList(new BuildingRenderListEventArgs( _renderList, context.Camera)); _commandList.Begin(); if (context.Scene != null) { _commandList.PushDebugGroup("3D Scene"); Render3DScene(_commandList, context.Scene, context); _commandList.PopDebugGroup(); } else { _commandList.SetFramebuffer(_intermediateFramebuffer); _commandList.ClearColorTarget(0, ColorRgba.DimGray.ToColorRgbaF().ToRgbaFloat()); } // GUI and camera-dependent 2D elements { _commandList.PushDebugGroup("2D Scene"); _drawingContext.Begin( _commandList, context.Game.ContentManager.LinearClampSampler, new SizeF(context.Game.Viewport.Width, context.Game.Viewport.Height)); context.Game.Scene3D?.Render(_drawingContext); context.Game.Scene2D.Render(_drawingContext); context.Game.RaiseRendering2D(new Rendering2DEventArgs(_drawingContext)); _drawingContext.End(); _commandList.PopDebugGroup(); } _commandList.PushDebugGroup("Blitting to screen"); _commandList.SetFramebuffer(context.RenderTarget); _intermediateSpriteBatch.Begin( _commandList, context.GraphicsDevice.PointSampler, new SizeF(_intermediateTexture.Width, _intermediateTexture.Height), ignoreAlpha: true); _intermediateSpriteBatch.DrawImage(_intermediateTexture, null, new Mathematics.RectangleF(0, 0, (int)_intermediateTexture.Width, (int)_intermediateTexture.Height), ColorRgbaF.White); _intermediateSpriteBatch.End(); _commandList.PopDebugGroup(); _commandList.End(); context.GraphicsDevice.SubmitCommands(_commandList); context.GraphicsDevice.SwapBuffers(); }