Help combining code to obtain a amazing DOF effect

Blitz3D Forums/Blitz3D Programming/Help combining code to obtain a amazing DOF effect

Pinete(Posted 2006) [#1]
I'm trying to combine two pieces of code in order
to obtain a better Depth Of Field effect.
The first one is the dof code of fredborg, in the code archives, and the second one is the texture blurring function of sswift.
What I'm trying is to blur each layer created by Fredborg function, in order to obtain more quality in the blurring depending of distance, but I'm bot capable of do it and the results are all bizarre.

please, someone could help me?

This is the link to Fredbrog function:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1030



and this is the code of sswift blur routine:

; Blur init
;-----------
Global blur_qual = 2 
Global blur_rad# = 3
Global blur_coef# = .2
Global blur_decal# = .002
Global glow_tex,glow_tex2
Global mv_x#,mv_y#
Global tour

Const nb_filtres = 3
Const glowsize# = 512 

Const GLOW_CAM_X# = 65536.0 
Const GLOW_CAM_Y# = 65536.0 
Const GLOW_CAM_Z# = 0.0 



Function BlurTextureGlow(Texture, Blur_Quality, Blur_Radius#) 
	
	Local BlurMesh[16*4] 
	If Blur_Quality > 0 
		Blur_Cam = CreateCamera() 
		CameraRange Blur_Cam, 0.1, 1000 
		CameraZoom Blur_Cam, 16.0 ;16.0
		RotateEntity Blur_Cam, 90, 0, 0, True 
		CameraViewport Blur_Cam, 0, 0, TextureWidth(Texture), TextureHeight(Texture) 
		CameraClsColor Blur_Cam, 0,0,0 
		CameraClsMode Blur_Cam, True, True 
		PositionEntity Blur_Cam, GLOW_CAM_X#, GLOW_CAM_Y#, GLOW_CAM_Z# 
		For Loop = 0 To (Blur_Quality*4)-1 
			BlurMesh[Loop] = CreateSprite() 
		Next 
		ScaleTexture Texture, 0.5, 0.5 
		PositionTexture Texture, 0.5, 0.5 
		BlurRadius# = Blur_Radius# * (1.0 / 256.0) 
		BlurAngleStep# = 360.0 / Float(Blur_Quality*4) 
		BlurShade = Ceil(255.0 / Float(Blur_Quality*4)) 
		For Loop = 0 To (Blur_Quality*4)-1 
			EntityTexture BlurMesh[Loop], Texture 
			EntityFX BlurMesh[Loop], 1+8 
			EntityAlpha BlurMesh[Loop], 1.0 / Float(Loop+1) 
			ScaleSprite BlurMesh[Loop], 2, 2 
			BlurAngle# = BlurAngleStep# * Float(Loop) + 180.0*(Loop Mod 2) 
			Xoff# = BlurRadius# * Cos(BlurAngle#) 
			Yoff# = BlurRadius# * Sin(BlurAngle#)PositionEntity BlurMesh[Loop], GLOW_CAM_X# + Xoff#, GLOW_CAM_Y# - 16.0, GLOW_CAM_Z# + Yoff#, True 
		Next 
		RenderWorld 
		CopyRect 0, 0, TextureWidth(Texture), TextureHeight(Texture), 0, 0, BackBuffer(), TextureBuffer(Texture) 
		For Loop = 0 To (Blur_Quality*4)-1 
			FreeEntity BlurMesh[Loop] 
		Next 
		HideEntity Blur_Cam 
		FreeEntity Blur_Cam 
	EndIf 
	
End Function



jfk EO-11110(Posted 2006) [#2]
( What are the forum codes? )


Pinete(Posted 2006) [#3]
code archives, sorry
:)


jfk EO-11110(Posted 2006) [#4]
my point was: people tend to help more if you are using the CODE tags, unformated code is scaring them somewhat. (since you posted it without the CODE tags in the first place).

I'd like to help you with your problem but I didn't have the the time to check it out. How about to post the combined version of the two sources, no matter how bizarre the results are?


Pinete(Posted 2006) [#5]
Thanks jfk,
first of all in order to avoid pit the code without format, could you please say me how could I put the code? what "tags" I need to put and where?
I will put the combined version today!
:)

Thanks a lot,


jfk EO-11110(Posted 2006) [#6]
scroll down and read at What are the forum codes?