public void Draw() { if (!isVisible) { return; } if (GraphicsEnabled) { GameLoop.gameInstance.GraphicsDevice.SetRenderTarget(renderTargets[1]); GameLoop.gameInstance.graphics.PreferMultiSampling = true; foreach (Layer l in layerList) { Vector2 oldCameraPosition = Camera.Position; Camera.Position *= l.ScrollSpeed; Effect effect = l.getShaderByType(l.shaderType); // Testweise MotionBlur eingefügt für alle Layer außer Player-Layer if (l != GameLoop.gameInstance.playerInstance.layer && false) { effect = EffectManager.MotionBlur(GameLoop.gameInstance.playerInstance.charRect.Body.LinearVelocity * (new Vector2(1, 1) + l.ScrollSpeed)); } spriteBatch.Begin(SpriteSortMode.Deferred, l.getBlendStateByEffect(l.shaderType), null, null, null, effect, Camera.matrix); l.drawLayer(spriteBatch); spriteBatch.End(); camMovement = oldCameraPosition - Camera.Position; Camera.Position = oldCameraPosition; } GameLoop.gameInstance.GraphicsDevice.SetRenderTarget(renderTargets[2]); GameLoop.gameInstance.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, EffectManager.Godrays()); spriteBatch.Draw(renderTargets[1], Vector2.Zero, Color.White); spriteBatch.End(); GameLoop.gameInstance.GraphicsDevice.SetRenderTarget(renderTargets[3]); GameLoop.gameInstance.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, EffectManager.Bloom()); spriteBatch.Draw(renderTargets[2], Vector2.Zero, Color.White); spriteBatch.End(); GameLoop.gameInstance.GraphicsDevice.SetRenderTarget(renderTargets[4]); GameLoop.gameInstance.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, EffectManager.VignettenBlur()); spriteBatch.Draw(renderTargets[2], Vector2.Zero, Color.White); spriteBatch.Draw(renderTargets[1], Vector2.Zero, Color.White); spriteBatch.Draw(renderTargets[3], Vector2.Zero, Color.White); spriteBatch.End(); GameLoop.gameInstance.GraphicsDevice.SetRenderTarget(null); GameLoop.gameInstance.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null); spriteBatch.Draw(renderTargets[4], Vector2.Zero, Color.White); spriteBatch.End(); spriteBatch.Begin(); Primitives.Instance.drawBoxFilled(spriteBatch, new Rectangle(0, 0, GameSettings.Default.resolutionWidth, 96), Color.Black); Primitives.Instance.drawBoxFilled(spriteBatch, new Rectangle(0, GameSettings.Default.resolutionHeight - 96, GameSettings.Default.resolutionWidth, 96), Color.Black); spriteBatch.End(); } if (DebugViewEnabled) { debugView.RenderDebugData(ref proj, ref Camera.debugMatrix); } }