• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
  • comments
  • views

Bloom on Windows Phone

Sign in to follow this  
Followers 0


Ok, silliness aside, is it possible to implement an efficient bloom effect on Windows Phone without custom shaders?
Bloom consists of three operations:

  1. Identify which parts of the image should be bloomed
  2. Blur those parts
  3. Combine blurred bloomy bits with the original image

There are many choices for how each operation should be implemented, the combination of which determines the visual result. In the XNA bloom sample:

  1. Bright areas are identified by subtracting a threshold value, then scaling back up to preserve full color range: (value - threshold) / (1 - threshold)
  2. Blur is applied using a two pass separable Gaussian filter
  3. To avoid excessively bright areas, the final combine operation is: (base * (1 - bloom)) + bloom (done in a pixel shader that also provides brightness and saturation adjustment for both images)

There is no good way to adjust saturation without shaders, but everything else in this design can be done with simple alpha blending operations: using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BloomPostprocess
public class BloomComponent : DrawableGameComponent
// Adjust these values to change visual appearance.
const float BloomThreshold = 0.25f;
const float BloomIntensity = 1.5f;
const int BlurPasses = 4;

// result = source - destination
static BlendState extractBrightColors = new BlendState
ColorSourceBlend = Blend.One,
AlphaSourceBlend = Blend.One,

ColorDestinationBlend = Blend.One,
AlphaDestinationBlend = Blend.One,

ColorBlendFunction = BlendFunction.Subtract,
AlphaBlendFunction = BlendFunction.Subtract,

// result = source + destination
static BlendState additiveBlur = new BlendState
ColorSourceBlend = Blend.One,
AlphaSourceBlend = Blend.One,

ColorDestinationBlend = Blend.One,
AlphaDestinationBlend = Blend.One,

// result = source + (destination * (1 - source))
static BlendState combineFinalResult = new BlendState
ColorSourceBlend = Blend.One,
AlphaSourceBlend = Blend.One,

ColorDestinationBlend = Blend.InverseSourceColor,
AlphaDestinationBlend = Blend.InverseSourceColor,

SpriteBatch spriteBatch;

RenderTarget2D scene;
RenderTarget2D halfSize;
RenderTarget2D quarterSize;
RenderTarget2D quarterSize2;

public BloomComponent(Game game)
: base(game)
{ }

protected override void LoadContent()
spriteBatch = new SpriteBatch(GraphicsDevice);

PresentationParameters pp = GraphicsDevice.PresentationParameters;

int w = pp.BackBufferWidth;
int h = pp.BackBufferHeight;

scene = new RenderTarget2D(GraphicsDevice, w, h, false, pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents);
halfSize = new RenderTarget2D(GraphicsDevice, w / 2, h / 2, false, pp.BackBufferFormat, DepthFormat.None);
quarterSize = new RenderTarget2D(GraphicsDevice, w / 4, h / 4, false, pp.BackBufferFormat, DepthFormat.None);
quarterSize2 = new RenderTarget2D(GraphicsDevice, w / 4, h / 4, false, pp.BackBufferFormat, DepthFormat.None);

public void BeginDraw()
if (Visible)

public override void Draw(GameTime gameTime)
// Shrink to half size.
DrawSprite(scene, BlendState.Opaque);

// Shrink again to quarter size, at the same time applying the threshold subtraction.
GraphicsDevice.Clear(new Color(BloomThreshold, BloomThreshold, BloomThreshold));
DrawSprite(halfSize, extractBrightColors);

// Kawase blur filter (see http://developer.amd.com/media/gpu_assets/Oat-ScenePostprocessing.pdf)
for (int i = 0; i < BlurPasses; i++)

int w = quarterSize.Width;
int h = quarterSize.Height;

float brightness = 0.25f;

// On the first pass, scale brightness to restore full range after the threshold subtraction.
if (i == 0)
brightness /= (1 - BloomThreshold);

// On the final pass, apply tweakable intensity adjustment.
if (i == BlurPasses - 1)
brightness *= BloomIntensity;

Color tint = new Color(brightness, brightness, brightness);

spriteBatch.Begin(0, additiveBlur);

spriteBatch.Draw(quarterSize, new Vector2(0.5f, 0.5f), new Rectangle(i + 1, i + 1, w, h), tint);
spriteBatch.Draw(quarterSize, new Vector2(0.5f, 0.5f), new Rectangle(-i, i + 1, w, h), tint);
spriteBatch.Draw(quarterSize, new Vector2(0.5f, 0.5f), new Rectangle(i + 1, -i, w, h), tint);
spriteBatch.Draw(quarterSize, new Vector2(0.5f, 0.5f), new Rectangle(-i, -i, w, h), tint);


Swap(ref quarterSize, ref quarterSize2);

// Combine the original scene and bloom images.
DrawSprite(scene, BlendState.Opaque);
DrawSprite(quarterSize, combineFinalResult);

void DrawSprite(Texture2D source, BlendState blendState)
spriteBatch.Begin(0, blendState);
spriteBatch.Draw(source, GraphicsDevice.Viewport.Bounds, Color.White);

static void Swap(ref T a, ref T b)
T tmp = a;
a = b;
b = tmp;

  • High quality blur filters can be expensive, so most bloom implementations do a cheap bilinear downsample to lower resolution before the 'real' blur. The original XNA sample operates at half resolution, but in a nod to the limited bandwidth of mobile GPUs, I made this version shrink to quarter size.

  • It is possible to implement Gaussian blur (or indeed any multi-tap filter) as a series of additive and subtractive blends with suitable offsets, but that gets expensive for large filter kernels. Instead I chose a Kawase blur (originally developed by Masaki Kawase for the Xbox1 game Wreckless), which cunningly exploits GPU bilinear filtering to get a not-quite-as-good-but-still-ok result more cheaply.

  • The threshold subtraction is perhaps the least intuitive operation. We want (source - threshold), but the alpha blending hardware only gives us (source - destination). So, we simply clear the destination rendertarget to our desired threshold value before drawing the source image!

  • There are two scaling operations in this bloom design: one to preserve full color range after the threshold subtraction, and a second after the blur to adjust intensity of the bloom. For efficiency, I apply these adjustments during the first and last blur passes, getting them for free as a side effect of drawing work that was already taking place.

    So how does it look?
    With BloomThreshold = 0.25f, BloomIntensity = 1.5f, BlurPasses = 4:


    With BloomThreshold = 0.5f, BloomIntensity = 3, BlurPasses = 6:


    With BloomThreshold = 0, BloomIntensity = 1.5f, BlurPasses = 3:



Sign in to follow this  
Followers 0


There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now