Fast enough for real-time blur effect?

Monkey Forums/Monkey Programming/Fast enough for real-time blur effect?

Supertino(Posted 2013) [#1]
I am looking to creat a real-time blur effect, effectively calling a function in the render loop that will blur a specified region,for example;

BlurRegion( x:Int, y:Int, width:Int, height:int, strength:Float, softedge:Bool )


Anything rendered before this function call is blurred.

Just wondering if you guys think the pixel read/write commands in monkey fast enough to do this? If so can any one recommend some existing code I convert or a well written process I can follow?


ElectricBoogaloo(Posted 2013) [#2]
Not as far as I've managed it.
Mark's suggested that he's working on Shaders. Should be doable with that, but doing it via read/write it just wouldn't be achievable. (Unless others know other methods? Would be interesting to hear other methodology)

From my attempts, simply reading the screen results in halving the framerate, so I pretty much gave up soon after that.


skape(Posted 2013) [#3]
Don't know if you saw this, but it may give you some ideas. It might be possible to do realtime, but it's going to be expensive:
http://www.monkeycoder.co.nz/Community/posts.php?topic=4344#46349

Also, this could give you some ideas:
http://www.monkeycoder.co.nz/Community/posts.php?topic=4749#51740


But, ultimately, shaders are going to be your best friends. :)


Gerry Quinn(Posted 2013) [#4]
Maybe you could do it by painting the same image several times at slightly different positions with fractional alpha values. (After first painting with alpha = 1.0.)

Depends what your purpose is - obviously it's not a perfect blur but it might give an effect approximating what you want.


Paul - Taiphoz(Posted 2013) [#5]
You could also try, grabing the screen, rendering it at a thirds its current size and then scaling the smaller image upto full size the natural blurring through scaling might be enough for your needs.


Supertino(Posted 2013) [#6]
ah some how I didn't think the pixel commands would be enough, had flashbacks of the pixel commands back in BlitzPlus where you could only get away is a around a 32x32 area before your FPS plummeted.

Some neat alternatives though by Taiphoz and Gerry.


therevills(Posted 2013) [#7]
you could do it by painting the same image several times at slightly different positions with fractional alpha values. (After first painting with alpha = 1.0.)

I've done this a few times, looks pretty cool and nice and fast too :)


Gerry Quinn(Posted 2013) [#8]
"had flashbacks of the pixel commands back in BlitzPlus where you could only get away is a around a 32x32 area before your FPS plummeted"

I'd say you can probably do quite a bit of processing (CPUs are fast now, and mobile screens are small) - what I would worry more about is that you will have to load a new image into graphic memory every frame and I'm not sure whether that might not cause bottlenecks on some systems. Still, perhaps it would work fine, especially if your game isn't one that depends on a constant 60 FPS.