Simple Blur Effect

Started by
5 comments, last by MePHyst0 18 years, 5 months ago
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]
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
Advertisement
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
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


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
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
No, you render the game to a texture with rendertosurface. Then, set the texture which you just rendered to and draw a 2d box. Then present the screen.
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.
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 :)

This topic is closed to new replies.

Advertisement