1 /* === S I N F G =========================================================== */
2 /*! \file layer_motionblur.h
3 ** \brief Template Header
5 ** $Id: layer_motionblur.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
32 #include "layer_motionblur.h"
35 #include "paramdesc.h"
39 #include "valuenode.h"
44 /* === U S I N G =========================================================== */
46 using namespace sinfg;
50 /* === G L O B A L S ======================================================= */
52 SINFG_LAYER_INIT(Layer_MotionBlur);
53 SINFG_LAYER_SET_NAME(Layer_MotionBlur,"MotionBlur");
54 SINFG_LAYER_SET_LOCAL_NAME(Layer_MotionBlur,_("Motion Blur"));
55 SINFG_LAYER_SET_CATEGORY(Layer_MotionBlur,_("Blurs"));
56 SINFG_LAYER_SET_VERSION(Layer_MotionBlur,"0.1");
57 SINFG_LAYER_SET_CVS_ID(Layer_MotionBlur,"$Id: layer_motionblur.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $");
59 /* === M E M B E R S ======================================================= */
61 Layer_MotionBlur::Layer_MotionBlur():
62 Layer_Composite (1.0,Color::BLEND_STRAIGHT),
68 Layer_MotionBlur::set_param(const String ¶m, const ValueBase &value)
72 return Layer_Composite::set_param(param,value);
76 Layer_MotionBlur::get_param(const String ¶m)const
83 return Layer_Composite::get_param(param);
87 Layer_MotionBlur::set_time(Context context, Time time)const
89 context.set_time(time);
94 Layer_MotionBlur::set_time(Context context, Time time, const Point &pos)const
96 context.set_time(time,pos);
101 Layer_MotionBlur::get_color(Context context, const Point &pos)const
106 time+=(Vector::value_type)( (signed)(RAND_MAX/2)-(signed)rand() )/(Vector::value_type)(RAND_MAX) *aperture -aperture*0.5;
107 context.set_time(time, pos);
110 return context.get_color(pos);
114 Layer_MotionBlur::get_param_vocab()const
117 //ret=Layer_Composite::get_param_vocab();
119 ret.push_back(ParamDesc("aperture")
120 .set_local_name(_("Aperature"))
121 .set_description(_("Shutter Time"))
128 Layer_MotionBlur::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
130 if(aperture && quality<10)
133 SuperCallback subimagecb;
137 case 1: // Production Quality
140 case 2: // Excellent Quality
143 case 3: // Good Quality
146 case 4: // Moderate Quality
149 case 5: // Draft Quality
164 case 10: // Rough Quality
174 surface->set_wh(renddesc.get_w(),renddesc.get_h());
177 for(i=0;i<samples;i++)
179 subimagecb=SuperCallback(cb,i*(5000/samples),(i+1)*(5000/samples),5000);
180 context.set_time(time_cur+(aperture/samples)*i-aperture*0.5);
181 if(!context.accelerated_render(&tmp,quality,renddesc,&subimagecb))
183 for(int y=0;y<renddesc.get_h();y++)
184 for(int x=0;x<renddesc.get_w();x++)
185 (*surface)[y][x]+=tmp[y][x].premult_alpha();
187 for(int y=0;y<renddesc.get_h();y++)
188 for(int x=0;x<renddesc.get_w();x++)
189 (*surface)[y][x]=((*surface)[y][x]/(float)samples).demult_alpha();
192 return context.accelerated_render(surface,quality,renddesc,cb);