Bloom problem

Blitz3D Forums/Blitz3D Beginners Area/Bloom problem

I'm using bouncers excellent Bloom code, but I'm having a slight problem. It seems to be displaying my image in letterbox format with strange images at the top. I tried this at both 640x480 and 800x600. Any idea what the problem is?



Thanks in advance!

Without looking at the code I would guess cameraviewport.

CameraViewport wasn't defined (oops!), but defining doesn't seem to have made any diffence. Hmm.

Hmm... playing around with this but still not having much joy. It's a bit of a headache as this uses an old version of SSwift's blurtexture function, but the shadow system uses a new version! I realise the new one ought to be up to the task, but it doesn't seem to want to play ball. Hmm.

I broke the blur function in my shadow system for a long time.

This version of the blur function is up to date and should work:
http://www.blitzbasic.com/codearcs/codearcs.php?code=754

Playing around with the bloom code I have, it seems that even the demo I have suffers the exact same problem. I don't think it is sswift's blur code to blame. Does anyone have a working copy of Bouncer's bloom code that they could share?

Aha - I found a working version of the bloom code, so I seem to be alright now. Using this combined with SSwift's new blur routine will work perfectly.

;GLOW VARIABLES
Global GL_cam
Global GL_scenecam					;This stores the pointer to your scene camera
Global GL_offset = 65536			;Offset for the glow camera
Global GL_texsize = 256			;Glow texture resolution (128 or 256 recommended)
Global GL_camzoom# = 1.0		;Change this value if your camzoom differs from the default

Global GL_sprite
Global GL_tex,GL_texbuffer

Global GL_sprite_scene
Global GL_timer=1


;Initializes the filter
;--------------------------

;camera - your main scene camera
;NOTE - do not change camera rotation before calling this init function.
Function InitGlow(camera)
GL_scenecam = camera

;SET GLOW CAMERA
GL_cam = CreateCamera()
PositionEntity GL_cam,GL_offset,0,0
CameraProjMode GL_cam,2
CameraRange GL_Cam, 1, 100
CameraClsMode GL_cam,0,1
CameraViewport GL_cam,0,0,GL_texsize,GL_texsize
HideEntity GL_cam

;SET GLOW SPRITE 1 (FOR DARKENING PASSES)
GL_sprite = CreateSprite()
GL_tex = CreateTexture(GL_texsize,GL_texsize,256+16+32)
GL_texbuffer = TextureBuffer(GL_tex)
EntityTexture GL_sprite,GL_tex
PositionEntity GL_sprite,GL_offset,0,1
EntityOrder GL_sprite,-999
EntityFX GL_sprite,1

;SET GLOW SPRITE 2  (FINAL  OVERLAY)
GL_sprite_scene = CreateSprite()
EntityTexture GL_sprite_scene,GL_tex
ScaleSprite GL_sprite_scene,2*(1.0/GL_camzoom),2*(1.0/GL_camzoom)
PositionEntity GL_sprite_scene,EntityX(GL_scenecam),EntityY(GL_scenecam),EntityZ(GL_scenecam)+2
EntityParent GL_sprite_scene,GL_scenecam
EntityOrder GL_sprite_scene,-999
EntityFX GL_sprite_scene,1
End Function



;Renders the filter
;--------------------------

;fade - initial fade value for the scene
;dark_passes - how many multiply passes (darkening)
;glow_passes - how many blur / glow passes
;glare_size - blur radius

;just play with the values until you find a good combination.


;IMPORTANT NOTES
;* 		The scene camera will be hidden automatically...
;		but you must hide every other camera you might be using Before calling this Function.

;*		Also if you want to turn the blurring off you MUST HIDE the GL_sprite_scene object and stop calling this function (obviously :)

;* 		The more dark_passes and glow_passes - the slower the function is ... so beware.
;		Also switching to smaller texture size will boost performance.

Function RenderGlow(fade#=0.15,dark_passes=2,glow_passes=3,glare_size#=4)
;RENDER THE SCENE WITH MAIN CAMERA AND COPY TO TEXTURE
;Also apply the fade filter
HideEntity GL_sprite
EntityBlend GL_sprite_scene,1
EntityColor GL_sprite_scene,0,0,0
EntityAlpha GL_sprite_scene,fade

CameraViewport GL_scenecam,0,0,GL_texsize,GL_texsize
RenderWorld
CopyRect 1,1,GL_texsize-1,GL_texsize-1,0,0,BackBuffer(),GL_texbuffer
CameraViewport GL_scenecam,0,0,GraphicsWidth(),GraphicsHeight()

ShowEntity GL_sprite
EntityColor GL_sprite_scene,255,255,255
EntityAlpha GL_sprite_scene,1


;SWITCH TO GLOW CAMERA AND HIDE MAIN CAMERA
HideEntity GL_scenecam
ShowEntity GL_cam


;MULTIPLY BLEND WITH BACKBUFFER TO MAKE THE CONTRAST HIGHER
;(RESERVE THE LUMINATED AREAS)
EntityBlend GL_sprite,2		
For i=1 To dark_passes
RenderWorld 
Next
CopyRect 1,0,GL_texsize-1,GL_texsize,0,0,BackBuffer(),GL_texbuffer
EntityBlend GL_sprite,1
HideEntity GL_sprite


;BLUR AND PUT SOME GLOW ON THE TEXTURE
;MORE PASSES - MORE GLOW
HideEntity GL_cam
For i=1 To glow_passes
blurtexture(GL_tex,1,glare_size)
Next
ScaleTexture GL_tex, 1,1
PositionTexture GL_tex,0,0
TextureBlend GL_tex, 2

;SWITCH BACK TO NORMAL CAMERA
ShowEntity GL_scenecam

;BLEND WITH ADDITIVE BLENDING WITH THE SCENE
EntityBlend GL_sprite_scene,3
End Function



It's probably just a scale issue!

Good work, nice screenshot dude!