public virtual RenderTarget2D RenderToTexture(Texture2D input)
        {
            Texture2D snapshot = GetSceneSnapshot();

            Effect.Parameters["fFadeAmount"].SetValue(_fadeTime);
            Effect.Parameters["ColorMap2"].SetValue(snapshot);

            PostProcessor.DrawFullscreenQuad(GraphicsDevice, input, _renderTarget, Effect);

            return(_renderTarget);
        }
        public RenderTarget2D RenderToTexture(Texture2D input)
        {
            Texture2D colorMap = input;

            // Pass 1: Extract the bright parts of the image.
            _ExtractEffect.Parameters["Threshold"].SetValue(Settings.BloomThreshold);
            PostProcessor.DrawFullscreenQuad(GraphicsDevice, input, _bloomTarget1, _ExtractEffect);

            // Pass 2: draw from bloomTarget1 into bloomTarget2,
            // using a shader to apply a horizontal gaussian blur filter.
            SetBlurEffectParameters(_BlurEffect, 1.0f / (float)_bloomTarget1.Width, 0, 4);
            PostProcessor.DrawFullscreenQuad(GraphicsDevice, _bloomTarget1, _bloomTarget2, _BlurEffect);

            // Pass 3: draw from bloomTarget2 back into bloomTarget1,
            // using a shader to apply a vertical gaussian blur filter.
            SetBlurEffectParameters(_BlurEffect, 0, 1.0f / (float)_bloomTarget1.Height, 4);
            PostProcessor.DrawFullscreenQuad(GraphicsDevice, _bloomTarget2, _bloomTarget1, _BlurEffect);

            GraphicsDevice.SetRenderTarget(_finalTarget);
            GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

            // Final Pass: Combine the colormap and the bloom texture.
            _CombineEffect.Parameters["ColorMap"].SetValue(colorMap);
            _CombineEffect.Parameters["BloomIntensity"].SetValue(Settings.BloomIntensity);
            _CombineEffect.Parameters["OriginalIntensity"].SetValue(Settings.BaseIntensity);
            _CombineEffect.Parameters["BloomSaturation"].SetValue(Settings.BloomSaturation);
            _CombineEffect.Parameters["OriginalSaturation"].SetValue(Settings.BaseSaturation);

            PostProcessor.DrawFullscreenQuad(
                GraphicsDevice,
                _bloomTarget1,
                _finalTarget.Width,
                _finalTarget.Height,
                _CombineEffect);

            return(_finalTarget);
        }
Beispiel #3
0
        public virtual RenderTarget2D RenderToTexture(Texture2D input)
        {
            PostProcessor.DrawFullscreenQuad(GraphicsDevice, input, _renderTarget, Effect);

            return(_renderTarget);
        }