[Help] Theorizing Motion Blur

Blitz3D Forums/Blitz3D Programming/[Help] Theorizing Motion Blur

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I made a simple mesh transform motion blur. If someone would add a texture blur to this it might look okay. I'm not fully sure if my code is perfect though. The object is simply scaled in the direction of movement.

Graphics3D 800,600,0,2
SetBuffer BackBuffer()



cam = CreateCamera()
MoveEntity cam,0,0,-14



cube = CreateCube()
EntityShininess cube,0.8


light = CreateLight(3)
MoveEntity light,100,100,100
PointEntity light,cube

Dim Pos#(2)

motionblur = 1
Repeat


	angle = angle + 4
	PositionEntity cube,Cos(angle)*5,0,0
	RotateMesh cube,1,1,1
	
	
	currentx# = EntityX#(cube)
	currenty# = EntityY#(cube)
	currentz# = EntityZ#(cube)
	scalex# = 1.0+Abs(currentx#-Pos#(0))
	scaley# = 1.0+Abs(currenty#-Pos#(1))
	scalez# = 1.0+Abs(currentz#-Pos#(2))

	If KeyHit(57) Then motionblur=1-motionblur
	UpdateWorld
	If motionblur
		ScaleEntity cube,scalex#,scaley#,scalez#
		PositionEntity cube,(currentx#+Pos#(0))*0.5,(currenty#+Pos#(1))*0.5,(currentz#+Pos#(2))*0.5
	EndIf
	RenderWorld
	If motionblur Then 
		ScaleEntity cube,1/scalex#,1/scaley#,1/scalez#
		Text 0,0,"Press space - MOTION BLUR = ON"
		Text 0,15,"Scale factor ("+scalex#+","+scaley#+","+scalez#+")"
	Else
		Text 0,0,"Press space - MOTION BLUR = OFF"
	EndIf
	Flip

	
	Pos#(0) = currentx#
	Pos#(1) = currenty#
	Pos#(2) = currentz#
Until KeyHit(1)