Motion blur problems

Blitz3D Forums/Blitz3D Beginners Area/Motion blur problems

chwaga(Posted 2007) [#1]
I've been trying to implement a motion blur from the code archives, I had to butcher it to fit my needs, all is well, except there's one problem: The blur is dragging to the bottem right corner, as it shouldn't be. Here's a screenshot.





(NOTE: NOTHING IS MOVING IN THAT PICTURE EXCEPT A CUBE AT THE TOP, the anomaly is much subtle if the alpha is set lower...the screenshot is heavily blurred to show you the bug more visibly)

and here's the code



Global alpha#=.5
Global l_surface=CreateSprite(cam)
;Global width=GraphicsWidth()
;Global height=GraphicsHeight()

SpriteViewMode l_surface,2
PositionEntity l_surface,0,0,1
EntityOrder l_surface,-100

If displaywidth=1280 Then 
ScaleSprite l_surface, 1, .8

Else If displaywidth=1024 Then
ScaleSprite l_surface, 1, .75
Else If displaywidth=800 Then
ScaleSprite l_surface, 1, .75
EndIf  

Global l_texture=CreateTexture(displaywidth,displayheight,1+256)
TextureBlend l_texture,2
;ScaleTexture l_texture, (Float TextureWidth(l_texture)/Float width),(Float TextureHeight(l_texture)/Float Height)
ScaleTexture l_texture, (Float TextureWidth(l_texture)/Float displaywidth),(Float TextureHeight(l_texture)/Float displayheight)



EntityTexture l_surface,l_texture
EntityAlpha l_surface,.3

Function l_setAlpha();alpha#)

EntityAlpha l_surface,alpha#

End Function

Function l_update()

 
RenderWorld

 
CopyRect 0,0,displaywidth,displayheight,0,0,BackBuffer(),TextureBuffer(l_texture)
;CopyRect 0,0,width,height,0,0,FrontBuffer(),TextureBuffer(l_texture)

 
End Function 




b32(Posted 2007) [#2]
I don't know exactly what causes it, but you can solve it by using PositionTexture. On 1024x768 and 800x600, the offset I used is:
PositionTexture l_texture, -0.0001, -0.00075
after scaletexture


chwaga(Posted 2007) [#3]
I'll try that...


chwaga(Posted 2007) [#4]
OK...it sorta works, but still, some of the "frames" of the mblur are "staining" until i move that spot over something brighter...it isn't dragging though.


chwaga(Posted 2007) [#5]
by the way, I found this to work better:

If GraphicsWidth() = 1280 Then 

	PositionTexture l_texture, -0.00025, -0.0005
	
ElseIf GraphicsWidth() = 1024 Or GraphicsWidth() = 800 Then

	PositionTexture l_texture, -0.0005, -0.00051
	
EndIf 



chwaga(Posted 2007) [#6]
hello?


b32(Posted 2007) [#7]
After taking a closer look at it, I think the problem is caused by the sprite's position. It isn't aligned well enough with the camera. If you copyrect something on the texture, and the sprite is a little bit too much to the right, the blur will slide to the right.
As for your other problem, I don't understand what you mean exactly ? Here is the example as I tried it, could you adapt it to show or explain what is going wrong ?



chwaga(Posted 2007) [#8]
2 things: The example you posted is showing no blur at all, and second: What I mean by "staining" is this:


The picture was taken several seconds after moving the camera away from the curtains, I drew an arrow pointing at the "stain" that doesn't dissapear unless I move the stained area over something brighter in the scene


b32(Posted 2007) [#9]
Aha, I see what you mean now. It is strange that the example shows no blur, when I tried, I got this:

I'll take a look at the staining. However, it could be a problem if the code I posted doesn't work at your machine ..


chwaga(Posted 2007) [#10]
when i run the code posted i get this:



b32(Posted 2007) [#11]
Ah .. maybe it is the SetBuffer part in l_update() that causes that. I put it in there for testing, but it doesn't work on every PC.
Is it an alternative to keep the alpha value below 0.5 ? Because when I try that, the stains dissapear


chwaga(Posted 2007) [#12]
ahh...no. The stains do dissappear when alpha is under .5, but the motion blur is barely visible...I can't seem to see a solution to this...