time and space

time and space

  • 1.7k
  • 31
  • 57k

How to bloom a specific color or sprite?

Aug 6 2011 9:48 AM
I've been using the following example code to create bloom effects in my project:

http://create.msdn.com/en-US/education/catalog/sample/bloom

How can I change/configure this to bloom only a certain colour or a certain object (eg - a specific sprite)?

I tried the following (to bloom only the lasers), but it doesn't work:

protected override void Draw(GameTime gameTime)
{
  bloom.BeginDraw();
  bloom.Settings = BloomSettings.PresetSettings[7]; //bloom off

  GraphicsDevice.Clear(Color.Black);
 
  spriteBatch.Begin(SpriteSortMode.Deferred,
  BlendState.AlphaBlend, SamplerState.PointClamp,
  null, null, null);
 
  if (bombs.bombsAlive > 0)
  bombs.Draw(spriteBatch);

  spriteBatch.End();

  bloom.Settings = BloomSettings.PresetSettings[6]; //bloom on
  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
  SamplerState.PointClamp, null, null, null);

  if (lasers.lasersAlive > 0)
  lasers.Draw(spriteBatch);

  spriteBatch.End();
 
  bloom.Settings = BloomSettings.PresetSettings[7]; //bloom off
  spriteBatch.Begin(SpriteSortMode.Deferred,
  BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null);
 
  if (enemies.enemiesAlive > 0)
  enemies.Draw(spriteBatch);
 
  if (projectiles.bulletsAlive > 0)
  projectiles.Draw(spriteBatch);
 
  spriteBatch.End();
 
  base.Draw(gameTime);
}

I've tested my bloom settings 6 and 7 individually, and they work as they should, when tested on a complete scene.  BloomSettings.PresetSettings[6] creates bloom while BloomSettings.PresetSettings[7] has no bloom effects.

Anyone have any ideas?

Answers (1)