Motion Blur
From GameStudio Wiki
This is some cheap looking motion blur effect which doesn´t need a shader. Render to texture is needed and it is slower than the same effect would be with a shader. It can be used for some quite good looking radial blur. just activate the effect and change the views arc parameter.
//////////////////////////////////////////////////
////////////Motion Blur without Shader////////////
//////////////////////////////////////////////////
////11.08.2008////////////////by Nils Daumann/////
/////////////slindev.wordpress.com////////////////
//////////////////////////////////////////////////
var WS_MotionBlur_active = 0;
//starts the radial blur
void WS_MotionBlur_init(VIEW* view, var steps, var distance)
{
WS_MotionBlur_active = 1;
var n;
BMAP** bmaps = malloc(sizeof(BMAP*)*steps);
PANEL** panels = malloc(sizeof(PANEL*)*steps);
for(n = 0; n < steps; n++)
{
bmaps[n] = bmap_createblack(screen_size.x,screen_size.y,24);
panels[n] = pan_create("",n);
panels[n].bmap = bmaps[n];
set(panels[n],VISIBLE|TRANSLUCENT);
panels[n].alpha = 100/steps;
}
n = 0;
while(WS_MotionBlur_active)
{
view.bmap = bmaps[n];
n += 1;
n %= steps;
wait(-distance);
}
view.bmap = 0;
for(n = 0; n < steps; n++)
{
ptr_remove(panels[n]);
ptr_remove(bmaps[n]);
}
}
//removes the effect
void WS_MotionBlur_remove()
{
WS_MotionBlur_active = 0;
}
This is an example on how to use it for radial blur:
//activate the effect
WS_MotionBlur_init(camera,10,0.05);
var i = 0;
while(i < 50)
{
i += 10*time_step;
camera.arc = 60-i;
wait(1);
}
while(i > 0)
{
i -= 5*time_step;
camera.arc = 60-i;
wait(1);
}
//deactivate the effect
WS_MotionBlur_remove();
--Slin 12:58, 12 August 2008 (CEST)
