示例#1
0
        public Bloom(SpriteBatch spriteBatch, Settings settings, Effect bloomExtractEffect, Effect bloomEffect, Effect blurEffect)
            : base(spriteBatch)
        {
            if (settings == null) throw new ArgumentNullException("settings");
            if (bloomExtractEffect == null) throw new ArgumentNullException("bloomExtractEffect");
            if (bloomEffect == null) throw new ArgumentNullException("bloomEffect");
            if (blurEffect == null) throw new ArgumentNullException("blurEffect");

            this.settings = settings;

            //----------------------------------------------------------------
            // エフェクト

            this.bloomExtractEffect = new BloomExtractEffect(bloomExtractEffect);
            this.bloomEffect = new BloomEffect(bloomEffect);

            //----------------------------------------------------------------
            // レンダ ターゲット

            var pp = GraphicsDevice.PresentationParameters;
            var width = (int) (pp.BackBufferWidth * settings.MapScale);
            var height = (int) (pp.BackBufferHeight * settings.MapScale);

            bloomExtractMap = new RenderTarget2D(GraphicsDevice, width, height,
                false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);

            //----------------------------------------------------------------
            // ブラー

            blur = new GaussianBlur(blurEffect, spriteBatch, width, height,
                SurfaceFormat.Color, settings.Blur.Radius, settings.Blur.Amount);
        }
示例#2
0
        public Bloom(SpriteBatch spriteBatch, Settings settings, Effect bloomExtractEffect, Effect bloomEffect, Effect blurEffect)
            : base(spriteBatch)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (bloomExtractEffect == null)
            {
                throw new ArgumentNullException("bloomExtractEffect");
            }
            if (bloomEffect == null)
            {
                throw new ArgumentNullException("bloomEffect");
            }
            if (blurEffect == null)
            {
                throw new ArgumentNullException("blurEffect");
            }

            this.settings = settings;

            //----------------------------------------------------------------
            // エフェクト

            this.bloomExtractEffect = new BloomExtractEffect(bloomExtractEffect);
            this.bloomEffect        = new BloomEffect(bloomEffect);

            //----------------------------------------------------------------
            // レンダ ターゲット

            var pp     = GraphicsDevice.PresentationParameters;
            var width  = (int)(pp.BackBufferWidth * settings.MapScale);
            var height = (int)(pp.BackBufferHeight * settings.MapScale);

            bloomExtractMap = new RenderTarget2D(GraphicsDevice, width, height,
                                                 false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);

            //----------------------------------------------------------------
            // ブラー

            blur = new GaussianBlur(blurEffect, spriteBatch, width, height,
                                    SurfaceFormat.Color, settings.Blur.Radius, settings.Blur.Amount);
        }
示例#3
0
        protected override void LoadContent()
        {
            #region Effects

            bloomExtractEffect = EffectManager.Load<BloomExtractEffect>();
            bloomEffect = EffectManager.Load<BloomEffect>();

            #endregion

            #region Back buffers

            var pp = GraphicsDevice.PresentationParameters;
            var width = (int) (pp.BackBufferWidth * Settings.MapScale);
            var height = (int) (pp.BackBufferHeight * Settings.MapScale);

            bloomExtractMapBackBuffer = BackBufferManager.Load("BloomExtractMap");
            bloomExtractMapBackBuffer.Width = width;
            bloomExtractMapBackBuffer.Height = height;
            bloomExtractMapBackBuffer.MipMap = false;
            bloomExtractMapBackBuffer.SurfaceFormat = pp.BackBufferFormat;
            bloomExtractMapBackBuffer.DepthFormat = DepthFormat.Depth24Stencil8;
            bloomExtractMapBackBuffer.MultiSampleCount = 0;
            bloomExtractMapBackBuffer.Enabled = Enabled;

            #endregion

            #region Gaussian blur

            gaussianBlur = new GaussianBlur(RenderContext, width, height, bloomExtractMapBackBuffer.SurfaceFormat);
            gaussianBlur.LoadContent();
            gaussianBlur.Enabled = Enabled;

            #endregion

            base.LoadContent();
        }