/* === S Y N F I G ========================================================= */
-/*! \file layer_motionblur.h
+/*! \file layer_motionblur.cpp
** \brief Template Header
**
-** $Id: layer_motionblur.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
+** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
/* === G L O B A L S ======================================================= */
SYNFIG_LAYER_INIT(Layer_MotionBlur);
-SYNFIG_LAYER_SET_NAME(Layer_MotionBlur,"MotionBlur");
+SYNFIG_LAYER_SET_NAME(Layer_MotionBlur,"MotionBlur"); // todo: use motion_blur
SYNFIG_LAYER_SET_LOCAL_NAME(Layer_MotionBlur,_("Motion Blur"));
SYNFIG_LAYER_SET_CATEGORY(Layer_MotionBlur,_("Blurs"));
SYNFIG_LAYER_SET_VERSION(Layer_MotionBlur,"0.1");
-SYNFIG_LAYER_SET_CVS_ID(Layer_MotionBlur,"$Id: layer_motionblur.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $");
+SYNFIG_LAYER_SET_CVS_ID(Layer_MotionBlur,"$Id$");
/* === M E M B E R S ======================================================= */
aperture (0)
{
}
-
+
bool
Layer_MotionBlur::set_param(const String ¶m, const ValueBase &value)
{
- IMPORT(aperture);
+ IMPORT(aperture);
return Layer_Composite::set_param(param,value);
}
Layer_MotionBlur::get_param(const String ¶m)const
{
EXPORT(aperture);
-
+
EXPORT_NAME();
EXPORT_VERSION();
-
+
return Layer_Composite::get_param(param);
}
Time time(time_cur);
time+=(Vector::value_type)( (signed)(RAND_MAX/2)-(signed)rand() )/(Vector::value_type)(RAND_MAX) *aperture -aperture*0.5;
context.set_time(time, pos);
- }
+ }
*/
return context.get_color(pos);
}
{
Layer::Vocab ret;
//ret=Layer_Composite::get_param_vocab();
-
+
ret.push_back(ParamDesc("aperture")
- .set_local_name(_("Aperature"))
+ .set_local_name(_("Aperture"))
.set_description(_("Shutter Time"))
);
-
+
return ret;
}
bool
Layer_MotionBlur::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
- if(aperture && quality<10)
+ if(aperture && quality<=10)
{
//int x, y;
SuperCallback subimagecb;
samples=3;
break;
case 10: // Rough Quality
- default:
- samples=1;
+ default:
+ samples=2;
break;
-
+
}
-
+
+ if (samples == 1) return context.accelerated_render(surface,quality,renddesc,cb);
+
Surface tmp;
int i;
+ float scale, divisor = 0;
surface->set_wh(renddesc.get_w(),renddesc.get_h());
surface->clear();
-
+
for(i=0;i<samples;i++)
{
subimagecb=SuperCallback(cb,i*(5000/samples),(i+1)*(5000/samples),5000);
- context.set_time(time_cur+(aperture/samples)*i-aperture*0.5);
+ context.set_time(time_cur-(aperture*(samples-1-i)/(samples-1)));
if(!context.accelerated_render(&tmp,quality,renddesc,&subimagecb))
return false;
+ scale = 1.0/(samples-i);
+ divisor += scale;
for(int y=0;y<renddesc.get_h();y++)
for(int x=0;x<renddesc.get_w();x++)
- (*surface)[y][x]+=tmp[y][x].premult_alpha();
+ (*surface)[y][x]+=tmp[y][x].premult_alpha()*scale;
}
for(int y=0;y<renddesc.get_h();y++)
for(int x=0;x<renddesc.get_w();x++)
- (*surface)[y][x]=((*surface)[y][x]/(float)samples).demult_alpha();
+ (*surface)[y][x]=((*surface)[y][x]/divisor).demult_alpha();
}
else
return context.accelerated_render(surface,quality,renddesc,cb);
-
+
return true;
}