Sign in to follow this  

Motion Blur

This topic is 4346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to implement a simple motion blur effect in my scene. I understand the concept of blurring the previous frame over the current one, but am unaware of how to do this in DirectX. Could anyone point me to a directx tutorial or identify the functions used to accomplish this.

Share this post


Link to post
Share on other sites
What you could do is use a simple Render-To-Texture technique where you will render the entire scene or the object you want blurred to a texture and then add some alpha component to the texture and then shift it up/down/left or right and then do this a couple of times. Also setting the appropriate render states such as alpha blending. This will give you a simple blur effect but might prove costly.

Basically the pattern will involve the following.

#1 RenderToTexture the to be blurred object (Top_Left)
#2 RenderToTexture the to be blurred object (Top_Right)
#3 RenderToTexture the to be blurred object (Bottom_Left)
#4 RenderToTexture the to be blurred object (Bottom_Right)
#5 Setting appropriate render states (Alpha blending)
#6 Final composed scene are the textures rendered into a final texture or scene.
By writing an alpha component to the textures you can create a somewhat blurred effect.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Ok, I've kinda gone off track with how I was implementing this.
ATM i'm just using a normal mesh, with a material property that has an relatively low alpha value (0.3 i think). I render the initial object then trace back along the path it has travelled and render it a few more times along the track.

The object is rendering with some-what of a trail, but the blending between each of the objects looks crap. I would guess that the problem of this is my SetRenderState properites set for SRCBLEND and DESCBLEND. Could anyone suggests what values I should use for these as I progress through rendering the initial object and then its previous states.

Cheers.

Share this post


Link to post
Share on other sites
Ok, perhaps I haven't made myself exactly clear.

All i need to do now is render to the frame buffer is such a way that when I am render onto pixels that have already been rendered, the alpha value increases.

So in the end when I render my object multiple times the alpha gradually increases imitating a motion blurred effect.

I think all I need to do is set the write SRCBLEND and DESTBLEND variables.

Any suggestions?

Share this post


Link to post
Share on other sites
Sorry for the delayed reply,
If you haven't had any experience with alpha blending before you could look at some tutorials online and moving the texture a little bit outwards each time would be a trivial exercise.

Alpha blending tutorial on PieterG.com
Alpha blending tutorial on TwoKings

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
On the motion blur topic... are there any good resources for implementing a pixel-velocity-based technique rather than alpha blending multiple full frames?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
On the motion blur topic... are there any good resources for implementing a pixel-velocity-based technique rather than alpha blending multiple full frames?


I second this, anyone know of any?

Share this post


Link to post
Share on other sites
Cheers for all the info guys. With the help of those tutorials i've finally gotten my motion blur to start looking nice. I was just re-reading over the post - with regard to the render to target option that was suggested first, I'm not sure I understand how it works. If you render an image multiple times to a surface, shifting the position a little bit in each direction to give it a blurred look, would that mean that the texture would be too large for the original object, and therefore when it was applied to it, make the object suddenly shrink?

Perhaps I'm not understanding the technique, would anyone care to enlighten me?

Cheers :)

Share this post


Link to post
Share on other sites
Hi there,

It might be a bit late for you as you've already got it going, but here was another article I found very helpful in regards to setting up a simply blur effect ( Check out the first section - Setting up the Swap Chain ):

http://www.talula.demon.co.uk/postprocessing/postprocessing.html

This explains it pretty clearly to me - it might have also been what you implemented!

The bit on making the render target a larger power of 2 and then rescaling the texcoords also caters for any screen resolution changes.

Toan

Share this post


Link to post
Share on other sites

This topic is 4346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this