public override void Draw(GameTime gameTime) { #region Pass 1 // Use the default blend and depth configuration GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; // Set the main render target, here we'll draw the base scene GraphicsDevice.SetRenderTarget(MainSceneRenderTarget); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1f, 0); Player.Draw(gameTime); foreach (var room in Rooms) { room.Draw(gameTime); } foreach (var bullet in Bullets) { if (bullet.isInitialized()) { bullet.Draw(gameTime); } else { bullet.Initialize(_game); bullet.Load(); } } foreach (var enemy in Enemies) { enemy.Draw(gameTime); } Lamp.Draw(gameTime); Lamp2.Draw(gameTime); UI.Draw(gameTime, Player); #endregion #region Pass 2 // Set the render target as our bloomRenderTarget, we are drawing the bloom color into this texture GraphicsDevice.SetRenderTarget(FirstPassBloomRenderTarget); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1f, 0); if (Game.godMode) { Player.Draw(gameTime); } else { Player.DrawBlack(gameTime); } foreach (var room in Rooms) { room.DrawBlack(gameTime); } foreach (var enemy in Enemies) { enemy.DrawBlack(gameTime); } Lamp.DrawBloom(gameTime); Lamp2.DrawBloom(gameTime); UI.Draw(gameTime, Player); #endregion #region Multipass Bloom // Now we apply a blur effect to the bloom texture // Note that we apply this a number of times and we switch // the render target with the source texture // Basically, this applies the blur effect N times BlurEffect.CurrentTechnique = BlurEffect.Techniques["Blur"]; var bloomTexture = FirstPassBloomRenderTarget; var finalBloomRenderTarget = SecondPassBloomRenderTarget; for (var index = 0; index < PassCount; index++) { //Exchange(ref SecondaPassBloomRenderTarget, ref FirstPassBloomRenderTarget); // Set the render target as null, we are drawing into the screen now! GraphicsDevice.SetRenderTarget(finalBloomRenderTarget); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1f, 0); BlurEffect.Parameters["baseTexture"].SetValue(bloomTexture); FullScreenQuad.Draw(BlurEffect); if (index != PassCount - 1) { var auxiliar = bloomTexture; bloomTexture = finalBloomRenderTarget; finalBloomRenderTarget = auxiliar; } } #endregion #region Final Pass // Set the depth configuration as none, as we don't use depth in this pass GraphicsDevice.DepthStencilState = DepthStencilState.None; // Set the render target as null, we are drawing into the screen now! GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.Black); // Set the technique to our blur technique // Then draw a texture into a full-screen quad // using our rendertarget as texture IntegrateEffect.CurrentTechnique = IntegrateEffect.Techniques["Integrate"]; IntegrateEffect.Parameters["baseTexture"]?.SetValue(MainSceneRenderTarget); IntegrateEffect.Parameters["bloomTexture"]?.SetValue(FirstPassBloomRenderTarget); FullScreenQuad.Draw(IntegrateEffect); #endregion }