Sign in to follow this  
matthughson

Simple Blur Effect

Recommended Posts

Hey All, I'd like to incoperate a simple blur effect into my game. I'm I've read that you can do a simple blur simply by clearing your back buffer with a semi transparent color value, so that each frame gets drawn over top of the other. But now that I actually want to do it, I can't find any information :S Here is what I have tried (c# by the way):
	m_device.Clear(D3D.ClearFlags.Target, aColor.FromArgb(100, 0, 0, 0), 1.0f, 0);
The alpha value seems to have no effect. I'm sure I need to set up some additional stuff somewhere (perhaps the back buffer format?), but I can't figure out what. Any help would be great! Matt [Edited by - matthughson on October 22, 2005 1:12:21 AM]

Share this post


Link to post
Share on other sites
Simple blur effects can be done by rendering your scene to a texture, and then rendering it over your backbuffer with a constant alpha value(say 0.2), without clearing the backbuffer.

hope this helps

Share this post


Link to post
Share on other sites
MePHyst0, what you suggest won't work for double or triple buffered swap chains. what you should do instead is each frame:

1. render the scene to the back buffer
2. alpha blend texture of prev frame onto back buffer
3. copy back buffer to texture of prev frame


Share this post


Link to post
Share on other sites
Quote:
Original post by blackpawn
MePHyst0, what you suggest won't work for double or triple buffered swap chains. what you should do instead is each frame:

1. render the scene to the back buffer
2. alpha blend texture of prev frame onto back buffer
3. copy back buffer to texture of prev frame


Does that mean I would be calling Present twice a frame?

Matt

Share this post


Link to post
Share on other sites
actually what i was suggesting is render to the back buffer not a texture. then alpha blend the texture from the prev frame onto the back buffer. and finally copy the data from the back buffer to a texture (using CopyRects or StretchBlt).

at the beginning of the frame you don't care what's in the back buffer (which is good cuz you can present with discard) and you have the previous frame in a texture. at the end of the frame you have the current frame in both the back buffer and the texture.

Share this post


Link to post
Share on other sites
yes, the back-buffer trick is not a bad idea. But copying the data from GPU to system memory(back-buffer content->prev. frame texture) and then back (prev. frame texture -> blend -> backbuffer), will be terribly slow. So, if you don't have plenty of performance to waste, be avare of this method :)

Share this post


Link to post
Share on other sites

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