/// <summary> /// Unloads the effects of this pipeline and the temporary RenderTargets, if you didn't pass them in the /// <see cref="Initialize" /> method.<br /> /// Please call this in the UnloadContent() method of your game. /// </summary> public void UnloadContent() { EmbeddedEffectsManager.UnloadContent(); if (!IsBloomRenderTarget1Passed) { BloomRenderTarget1?.Dispose(); } if (!IsBloomRenderTarget2Passed) { BloomRenderTarget2?.Dispose(); } }
/// <summary> /// Initializes the renderer.<br /> /// Please call this in the initialize method of your game (or at least before the first draw-call). /// </summary> /// <param name="graphicsDevice">The <see cref="GraphicsDevice" /> to use for drawing.</param> /// <param name="resolution">The resolution of your output-target.</param> /// <param name="bloomRenderTarget1"> /// A temporary bloom render target1. Gets automatically created and disposed off if you /// pass null. If you pass one to this method, remember to dispose (unload) it yourself. /// </param> /// <param name="bloomRenderTarget2"> /// A temporary bloom render target2. Gets automatically created and disposed off if you /// pass null. If you pass one to this method, remember to dispose (unload) it yourself. /// </param> public void Initialize(GraphicsDevice graphicsDevice, Point resolution, RenderTarget2D bloomRenderTarget1 = null, RenderTarget2D bloomRenderTarget2 = null) { // Create two render-targets for the bloom processing. These are half the // size of the back-Buffer, in order to minimize fill-rate costs. Reducing // the resolution in this way doesn't hurt quality, because we are going // to be blurring the bloom images anyway. if (BloomRenderTarget1 == null || BloomRenderTarget1.Width != resolution.X || BloomRenderTarget1.Height != resolution.Y) { if (BloomRenderTarget1 != null) { BloomRenderTarget1.Dispose(); BloomRenderTarget2.Dispose(); } if (bloomRenderTarget1 == null) { BloomRenderTarget1 = new RenderTarget2D(graphicsDevice, width: resolution.X / 2, height: resolution.Y / 2, mipMap: false, preferredFormat: SurfaceFormat.Color, preferredDepthFormat: DepthFormat.None); } else { BloomRenderTarget1 = bloomRenderTarget1; IsBloomRenderTarget1Passed = true; } if (bloomRenderTarget2 == null) { BloomRenderTarget2 = new RenderTarget2D(graphicsDevice, width: resolution.X / 2, height: resolution.Y / 2, mipMap: false, preferredFormat: SurfaceFormat.Color, preferredDepthFormat: DepthFormat.None); } else { BloomRenderTarget2 = bloomRenderTarget2; IsBloomRenderTarget2Passed = true; } } }