The fastest blur in the west?

BlitzMax Forums/BlitzMax Programming/The fastest blur in the west?

DirectX only at the moment, OGL is not working!

The example is just a simple image, you could use this to blur a render of the whole screen for super glow effects.

Loosly based on : http://www.gamasutra.com/features/20040526/james_01.shtml

Zero Bloom Passes (not really bloom but it looks nice)

One Bloom Pass

Strict

Import Indiepath.Render2Texture

' Inspired by sswifts accelerated blur function
' Copyright Indiepath 2006
' Written by Tim Fisher.

DebugLog "MOD_Bloom.bmx"

Function BlurImage:TImage(image:TImage,Quality:Int=1,Radius:Float=1,Passes:Int=1)

	Local Angle_Step:Float = 360.0 / Float(Quality * 4)
	Local Angle:Float
	Local xOff:Float
	Local yOff:Float
	
	SetBlend(ALPHABLEND)
	SetAlpha(1)
	
	Local temp:TImage = tRender.Create(image.width,image.height,image.flags)
	
	tRender.TextureRender_Begin(temp,False)
	
		tRender.Cls($00000000)
		DrawImage(image,0,0)

		SetAlpha(0.5)
	
		For Local loop:Int = 0 To (Quality * 4) - 1
			Angle = Angle_Step * Float(loop) + 180.0 * Float(loop Mod 2)
			xOff = Radius * Cos(Angle)
			yOff = Radius * Sin(Angle)
			DrawImage(temp,xOff,yOff)
		Next
		
		PrimaryDevice.device.SetRenderState D3DRS_ALPHATESTENABLE,False
		PrimaryDevice.device.SetRenderState( D3DRS_ALPHABLENDENABLE, True );
		PrimaryDevice.device.SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE    );
		PrimaryDevice.device.SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE   );
	
		For Local loop:Int = 1 To Passes
			DrawImage temp,0,0
		Next
	
	tRender.TextureRender_End()

		image = Null
	SetBlend(ALPHABLEND)
	Return temp

End Function

Strict


Import "MOD_Bloom.bmx"

Graphics 640,480,0


tRender.Initialise()


Local logo:Timage = LoadImage("bmax160_2.png",FILTEREDIMAGE|MIPMAPPEDIMAGE)

Local Quality = 10
Local Radius = 4
Local Passes = 0
logo = BlurImage(logo,Quality,Radius,Passes)

tRender.BackBufferRender_Begin()

	tRender.Cls($FF000000)
	DrawImage logo,200,130
	
tRender.BackBUfferRender_End()

Flip

WaitKey()