Skip to main content
GameDev.net gamedev.net
🔒 Locked

Blurring the Screen

Started by bmxouch Jun 3, 2004 at 12:37 PM 4 replies 650+ views
Original Post
bmxouch
bmxouch
I am creating a game that interfaces with a device called an EEG Biofeedback device. The device reads brainwave data from a user and returns it to the computer. My game reads that information, and tries to give feedback to the user. What I am trying to do is create a blurring effect based on the brainwave data. I need it to be able to blur more or less. So, how do I blur the screen. Is there anyway to make it less blurry or more blurry? Thanks, any help is greatly appriciated.
B, Out
Rasmadrak
Rasmadrak
you could render the screen to a texture that increases/or decreases in size. =)
* Correction:
first: set a new viewport that is smaller than the one you got for the moment.

draw everything.

render to texture. (remember that you need power-of-two textures!)

switch back to the old viewport (i.e the original)

draw a quad that is the same size as the current viewport with the texture created in "render to texture"
- since the texture was created in a smaller viewport it will become stretched (thus blurred).

this is the common way of doing camerafocus in games etc.
Look up "Render to texture" or "Radial Blur" in the RedBook or on NeHe´s site!

Cheers mate!


[edited by - Rasmadrak on June 3, 2004 1:52:24 PM]
"Game Maker For Life, probably never professional thou." =)
serratemplar
serratemplar
This will seem unrelated at first, but let me get to my point.

Not sure how much this might help, but back when I was in high school our computer class was introduced to Second Reality - a demo by a bunch of guys called Future Crew. One of the elements of the demo was a smoke/plasma field that looked like billowing flowing plasma.

I managed to replicate the effect by generating random intense points throughout a field of black (at some set frequency, I forget what), and also the bottom of the display buffer (an undrawn line) was a long line of color-values constantly being set high in intensity, varying from max to nearly zero.

This buffer was an array, we''ll say PlasmaBuffer[m][n]. What I did was run thru the array, either one at a time or every other space - depending on how intense/faded I wanted the plasma to appear, and I *averaged* the values of whatever one I was checking with the pixel immediately next to it (up, down, left, or right of it...it depended on the direction I wanted the plasma to "flow").

I lost this code in a pretty nasty harddrive crash years back, and recently I''ve been considering trying to reconstruct it for an effect in some of my little 2d games. The reason I mention it now is that it occured to me that using a similiar method - averaging neighboring pixel-color values - *might* add a blur effect. I don''t know, but that''s basicaly what it did with the plasma, so to a degree that might help you. If you''re doing it in 3d, I guess you''d have to do it to the 2d image you render to just before you flash it to the screen...unless there''s some fancy way to do it with that alpha-blending stuff. I really don''t know.

Good luck.
Steadtler
Steadtler
The most widly used blurring function is, for numerous mathematical considerations ,the gaussian function.
http://mathworld.wolfram.com/GaussianFunction.html

The sigma factor control the level of blurring.

So all you have to do is create a filter representating a 2d gaussian. The size of the filter should be rougly equal to 2.2 * sigma, if you want to keep your colors right.

Then you convolve your filter with each band of the image.

http://mathworld.wolfram.com/Convolution.html

A simpler mean of blurring the image is the mean function. That is, you set every pixel of the image as the mean of the 4 or 8 pixels around. You can control the level of blur by:

-Adding a factor, like new color = 50% color of the pixel + 50 % color of its neigbor

-If you want to blur more than 100% color of its neigbors, you can run the algorithm several time, or use the mean of the 20 closest pixels, 48 closest pixels, etc.

Have fun!
Dreddnafious Maelstrom
Dreddnafious Maelstrom
if you are using DirectX, there is a sample in the docs called, Depth of Field that covers blurring pretty well.

Dredd
________________________________________

"To die with your sword still in its sheath is most regrettable" -- Miyomoto Musashi


"Let Us Now Try Liberty"-- Frederick Bastiat
red_sodium
red_sodium
Awesome, are you trying to create a mind-reading game? How does this device work?

Red Sodium
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. - Terry Pratchett

[edited by - red_sodium on June 4, 2004 11:55:36 AM]
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.