Making blur effect?

BlitzMax Forums/BlitzMax Programming/Making blur effect?

orgos(Posted 2009) [#1]
Hello people.

I want to make a blur effect, but the problem is that I need to apply the blur effect to entirely screen without affect some sprites. Having a list of sprites, I draw the sprites that must receive the effect, apply the effect and then draw other sprites that not need the effect. In theory is that. I need to make this and make it really fast. Some one can help me, with code?


Ked(Posted 2009) [#2]
Nothing in BlitzMax is fast enough. Hopefully, it will be implemented soon because a lot of people (including me) have been wanting buffer commands.


Arowx(Posted 2009) [#3]
You could use an set of alpha/transparent trail of images to create a kind of motion blur effect?

Even better effects if you preprocessed the sprites in an image editor first to give them a blur!

Come to think of it if you use a reduced scale sprite and then scale it up you get a kind of blurring effect if you use the MIPMAPPED image flag.

The only other way I have heard of is writing a shader that will post process you graphics but you have to delve into GPU Shader coding for that which is outside of my current skill set.


Nate the Great(Posted 2009) [#4]
I have seen real time blur for bmax in the code arcs I think.. anyway here is a little function I wrote!

Function DrawImageBlur(img:TImage, x1:Int, y1:Int, blur_radius:Float, frame:Int = 0)
Local alph:Float = GetAlpha()
Local x:Int = 0
Local y:Int = 0
Local dist# = 0

For x = -blur_radius To blur_radius
	For y = -blur_radius To blur_radius
		dist = Sqr(x*x+y*y)
		If dist <= blur_radius Then
			dist = blur_radius-dist
			If blur_radius = 0 Then blur_radius = 1
			dist = dist/blur_radius
			SetAlpha dist*alph
			DrawImage img,x1+x,y1+y,frame
		EndIf
	Next
Next

SetAlpha alph

End Function



Nate the Great(Posted 2009) [#5]
oops the code above is slightly bugged.. it still looks decent though.


orgos(Posted 2009) [#6]
Thanks for the responses but that can't solve my problem.

I have a lots of stuff rendering like images, sprites, guis and particles making a blur effect of each one goes really slow, so thinking the best way it's to make a post draw effect or some thing with the drawed elements.

So I guess need to get the drawed buffer and apply effect...

I test it making a grabpixmap before clip, but i'ts is really slow.


ImaginaryHuman(Posted 2009) [#7]
Eeee... code above is a good idea but not in terms of speed, unless you're not drawing too many sprites. Tonnes of overdraw going on there.


nawi(Posted 2009) [#8]
Make blurred version of each sprite beforehand, or atleast blur them non-real time. You're not telling us if you need a directional blur or just a static one. You can also load the image at half the size, and draw at twice the scale.


smilertoo(Posted 2009) [#9]
the best blur ive seen in bmax was done using opengl buffers.