Motion Blur on Windows Phone 7


Everytime we need to give the impression of Speed we go to Motion Blur. There are Loots of ways to implement this, the old classic idea is to use the “also old” Accumulation Buffer to create this effect, more modern approaches generates each frame a Velocity buffers and use it to distort the final image.

 As we are bored to say, WP7 does not support custom shaders, so we need to find a solution with the “old school” features like alpha blending, Stencil …
In this post i will talk about a very simple and efficient motion blur implementation using the accumulation buffer idea.
In few words, our technic (actually it is just a Post Effect) consists of:

  • Render our scene to a offscreen Render Target
  • Mix the previous generated image with a downsampled version of the last frame using alpha blending (!!!)
  • Downsample the result of the last pass (to be used in the next frame =P)

Quite simple !
I wont put the full xna source code. The first reason is because i did not implemented it using the xna directely (i actually used PloobsEngine layer) and second cause we dont learn the stuffs if we just copy and paste stuffs. I will just put the most important parts. (as always, i ignored some stuffs like filtering … and optimizate nothing)

To create a render target, you use:

RenderTarget2D rt1 =  new RenderTarget2D(device, width, height, mipmap, SurfaceFormat, DepthFormat, preferedMultisampleCount, RenderTargetUsage);

You will need to create 3 of this, one to render the scene, and another to hold the downsampled image and the last to hold intermediate values.
For the downsample image, use width/2 and height/2. The values of mipmap, SurfceFormat …. depends of your render options, usually we use the same configuration of our backbuffer, to get those, check the GraphicDevice.PresentationParameters property.

To render the scene to a render target use:

///set render target
device.SetRenderTargets(rt1);
///clear it
device.Clear(BackGroundColor);
///ALL YOUR DRAW CODE HERE ... SpriteBatch ... Model.Draw .... everything ...
///set another render target (setting another one, unset the current one =P)
///now the rt1 "is" a texture2D with your scene rendered to it
device.SetRenderTargets(rt2);

Now you need to Mix this with the last frame Content (and render this to another Render Target rt2)

///rt2 is already setted, clear it
device.Clear(BackGroundColor);
///render the scene texture
rHelper.RenderTextureComplete(rt1, Color.FromNonPremultiplied(255, 255, 255, 255), GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true);
///render the rt3 with alpha blending (the downsampled version ... WILL BE GENERATED IN THE FOLLOWING)
rHelper.RenderTextureComplete(rt3, Color.FromNonPremultiplied(255, 255, 255, Amount), GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp, BlendState.AlphaBlend);

The Amount variable controls the motion blur “Intensity”.
The render helper facility just do:

///IF THE PARAMETER IS NOT PASSED, USE NULL ... SPRITEBATCH WILL USE THE DEFAULT ONE
spriteBatch.Begin(SpriteSortMode, blenderState, samplerState, depthState, rasterizerState, effect, transform);
spriteBatch.Draw(texture, destination,source, color);
spriteBatch.End();

Now we need to generate the downsample version (put in the rt3 render target):

///set render target
device.SetRenderTargets(rt3);
///clear it
device.Clear(BackGroundColor);
rHelper.RenderTextureComplete(rt2, Color.White, rt2.Bounds, Matrix.Identity, rt1.Bounds, true);

Finally we just render the rt2 (the mixed results to the screen)

///set render target to be the screen (null)
device.SetRenderTargets(null);
///clear it
device.Clear(BackGroundColor);
rHelper.RenderTextureComplete(end, Color.White, GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true);

It is done !!!
You can use this with 2D/3D … WP7, XBOX , PC …
This is a basic and rudimentar motion blur technic, but can give good results, specially in WP7 !!!

In the future i will post some others approaches to Motion Blur using Shaders.

  1. #1 by developer php on 21 de julho de 2017 - 9:28 am

    Sites of interest we’ve a link to

  2. #2 by boyclever on 21 de julho de 2017 - 10:09 am

    Der Patch hat mal gar nichts, Nationen Gefecht wimmelt von Autoloadern gleich mal aus gemacht den Quatsch, Änderung am FoV ist ne Absolute Frechheit, einfach alle bestrafen die gute Monitore besitzen, ganz toll von WG. Der ganze kram Lagt nur noch trotz ordentlichem Ping und guter FPS. Totaler Reinfall dieser Patch, leider.

  3. #3 by hermes bracelet replica on 21 de julho de 2017 - 1:30 pm

    Your product or service was in such a awesome pricing I by no means attention ones excellence is hence excellent. Its awesome. It mother will certainly really like this at Holiday morning anytime she opens up gifts and it looks as though I spent far more, then again pricing ended up being exclusively very good!!

  4. #4 by http://www.ecova.es/weddingshoes.asp on 21 de julho de 2017 - 1:31 pm

    That product had been at such a ideal cost I not believed the actual excellent would be quite excellent. It’s perfect. The mother will likely enjoy they in Xmas morning where she opens present therefore looks like I invested way more, although rates was just great!!

  5. #5 by lace frontal on 21 de julho de 2017 - 2:06 pm

    Fantastic customer service – extremely joyful and will invest in lace frontal https://www.youtube.com/watch?v=ny8rUpI_98I yet again !

  6. #6 by Barbour Outlet store on 21 de julho de 2017 - 2:50 pm

    Hello there, awesome web site. All of the issues you created on were quite fascinating. I attempted to provide in the RSS feed to my news reader. Thanks
    Barbour Outlet store http://www.barbouroutlet.online

  7. #7 by http://www.fem.co.uk/ladypeep.aspx on 21 de julho de 2017 - 3:29 pm

    We have bought that brand regarding bracelet some times. Every single one is super cute, established very well, cannot tarnish then significant depending on what a single you buy additionally that a person award this at.

1 228 229 230
(não será publicado)