Fix bug with xaos interpolation, by setting all xaos values to zero first.

Remove unnecessary resize() in Interpolate().

These are from Simon Detheridge's PR:

Set file name padding in EmberRender and
EmberAnimate based on the log10() of how many images are getting rendered, rather than hardcoding it to 5.

Use non-locale-imbued stream for writing filename in EmberAnimate.

Properly cast immediate float value used with pow() in density filter kernel.
This commit is contained in:
mfeemster 2015-03-30 17:46:52 -07:00
parent e746ae33ab
commit 4067422075
7 changed files with 29 additions and 19 deletions

View File

@ -981,7 +981,8 @@ public:
{ {
for (size_t i = 0; i < XformCount(); i++) for (size_t i = 0; i < XformCount(); i++)
{ {
m_Xforms[i].SetXaos(i, 0);//First make each xform xaos array be maxXformCount elements long and set them to zero. for (size_t k = 0; k < XformCount(); k++)//First make each xform xaos array be maxXformCount elements long and set them to zero.
m_Xforms[i].SetXaos(k, 0);
//Now fill them with interpolated values. //Now fill them with interpolated values.
for (size_t j = 0; j < size; j++)//For each ember in the list. for (size_t j = 0; j < size; j++)//For each ember in the list.

View File

@ -395,7 +395,6 @@ public:
vector<T> c(2); vector<T> c(2);
Ember<T> localEmbers[4]; Ember<T> localEmbers[4];
bool smoothFlag = false; bool smoothFlag = false;
c.resize(2);
if (embers[0].m_Time >= time) if (embers[0].m_Time >= time)
{ {

View File

@ -32,7 +32,7 @@ bool EmberAnimate(EmberOptions& opt)
bool finishXml = false; bool finishXml = false;
bool appendXml = false; bool appendXml = false;
uint finalImageIndex = 0; uint finalImageIndex = 0;
uint i, channels, ftime; uint i, channels, ftime, padding;
string s, flameName, filename, inputPath = GetPath(opt.Input()); string s, flameName, filename, inputPath = GetPath(opt.Input());
ostringstream os; ostringstream os;
vector<Ember<T>> embers; vector<Ember<T>> embers;
@ -248,6 +248,7 @@ bool EmberAnimate(EmberOptions& opt)
//Final setup steps before running. //Final setup steps before running.
os.imbue(std::locale("")); os.imbue(std::locale(""));
padding = uint(log10((double)embers.size())) + 1;
renderer->SetEmber(embers); renderer->SetEmber(embers);
renderer->EarlyClip(opt.EarlyClip()); renderer->EarlyClip(opt.EarlyClip());
renderer->YAxisUp(opt.YAxisUp()); renderer->YAxisUp(opt.YAxisUp());
@ -300,7 +301,8 @@ bool EmberAnimate(EmberOptions& opt)
if (opt.Out().empty()) if (opt.Out().empty())
{ {
ostringstream fnstream; ostringstream fnstream;
fnstream << inputPath << opt.Prefix() << setfill('0') << setw(opt.FilenamePadding()) << ftime << opt.Suffix() << "." << opt.Format();
fnstream << inputPath << opt.Prefix() << setfill('0') << setw(padding) << ftime << opt.Suffix() << "." << opt.Format();
filename = fnstream.str(); filename = fnstream.str();
} }

View File

@ -291,7 +291,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
if (doScf) if (doScf)
os << os <<
" real_t scfact = pow(densityFilter->m_Supersample / (densityFilter->m_Supersample + 1.0), 2.0);\n"; " real_t scfact = pow(densityFilter->m_Supersample / (densityFilter->m_Supersample + 1.0), (real_t)2.0);\n";
} }
os << os <<
@ -518,7 +518,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
if (doScf) if (doScf)
os << os <<
" real_t scfact = pow(densityFilter->m_Supersample / (densityFilter->m_Supersample + 1.0), 2.0);\n"; " real_t scfact = pow(densityFilter->m_Supersample / (densityFilter->m_Supersample + 1.0), (real_t)2.0);\n";
} }
//Compute the size of the temporary box which is the block width + 2 * filter width x block height + 2 * filter width. //Compute the size of the temporary box which is the block width + 2 * filter width x block height + 2 * filter width.
@ -646,12 +646,13 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
"\n"; "\n";
if (doScf) if (doScf)
os << " filterSelect *= scfact;\n"; os <<
" filterSelect *= scfact;\n";
} }
else else
{ {
os os <<
<< " filterSelect = bucket.w;\n"; " filterSelect = bucket.w;\n";
} }
os << os <<
@ -775,7 +776,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
" int densityBoxBottomY;\n"; " int densityBoxBottomY;\n";
if (doScf) if (doScf)
os << " real_t scfact = pow((real_t)densityFilter->m_Supersample / ((real_t)densityFilter->m_Supersample + 1.0), 2.0);\n"; os << " real_t scfact = pow((real_t)densityFilter->m_Supersample / ((real_t)densityFilter->m_Supersample + 1.0), (real_t)2.0);\n";
} }
os << os <<

View File

@ -73,7 +73,6 @@ enum eOptionIDs
OPT_TIME, OPT_TIME,
OPT_DTIME, OPT_DTIME,
OPT_NFRAMES, OPT_NFRAMES,
OPT_FNPADDING,
OPT_SYMMETRY, OPT_SYMMETRY,
OPT_SHEEP_GEN, OPT_SHEEP_GEN,
OPT_SHEEP_ID, OPT_SHEEP_ID,
@ -350,7 +349,6 @@ public:
INITUINTOPTION(Frame, Eou(OPT_ANIM_GENOME, OPT_FRAME, _T("--frame"), 0, SO_REQ_SEP, "\t--frame=<val> Synonym for \"time\".\n")); INITUINTOPTION(Frame, Eou(OPT_ANIM_GENOME, OPT_FRAME, _T("--frame"), 0, SO_REQ_SEP, "\t--frame=<val> Synonym for \"time\".\n"));
INITUINTOPTION(Dtime, Eou(OPT_USE_ANIMATE, OPT_DTIME, _T("--dtime"), 1, SO_REQ_SEP, "\t--dtime=<val> Time between frames [default: 1].\n")); INITUINTOPTION(Dtime, Eou(OPT_USE_ANIMATE, OPT_DTIME, _T("--dtime"), 1, SO_REQ_SEP, "\t--dtime=<val> Time between frames [default: 1].\n"));
INITUINTOPTION(Frames, Eou(OPT_USE_GENOME, OPT_NFRAMES, _T("--nframes"), 20, SO_REQ_SEP, "\t--nframes=<val> Number of frames for each stage of the animation [default: 20].\n")); INITUINTOPTION(Frames, Eou(OPT_USE_GENOME, OPT_NFRAMES, _T("--nframes"), 20, SO_REQ_SEP, "\t--nframes=<val> Number of frames for each stage of the animation [default: 20].\n"));
INITUINTOPTION(FilenamePadding,Eou(OPT_USE_ANIMATE, OPT_FNPADDING, _T("--filename_padding"), 5, SO_REQ_SEP, "\t--filename_padding=<val> Number of zeros to pad frame numbers with in output filename [default: 5].\n"));
INITUINTOPTION(Loops, Eou(OPT_USE_GENOME, OPT_LOOPS, _T("--loops"), 1, SO_REQ_SEP, "\t--loops=<val> Number of times to rotate each control point in sequence [default: 1].\n")); INITUINTOPTION(Loops, Eou(OPT_USE_GENOME, OPT_LOOPS, _T("--loops"), 1, SO_REQ_SEP, "\t--loops=<val> Number of times to rotate each control point in sequence [default: 1].\n"));
INITUINTOPTION(Repeat, Eou(OPT_USE_GENOME, OPT_REPEAT, _T("--repeat"), 1, SO_REQ_SEP, "\t--repeat=<val> Number of new flames to create. Ignored if sequence, inter or rotate were specified [default: 1].\n")); INITUINTOPTION(Repeat, Eou(OPT_USE_GENOME, OPT_REPEAT, _T("--repeat"), 1, SO_REQ_SEP, "\t--repeat=<val> Number of new flames to create. Ignored if sequence, inter or rotate were specified [default: 1].\n"));
INITUINTOPTION(Tries, Eou(OPT_USE_GENOME, OPT_TRIES, _T("--tries"), 10, SO_REQ_SEP, "\t--tries=<val> Number times to try creating a flame that meets the specified constraints. Ignored if sequence, inter or rotate were specified [default: 10].\n")); INITUINTOPTION(Tries, Eou(OPT_USE_GENOME, OPT_TRIES, _T("--tries"), 10, SO_REQ_SEP, "\t--tries=<val> Number times to try creating a flame that meets the specified constraints. Ignored if sequence, inter or rotate were specified [default: 10].\n"));
@ -480,7 +478,6 @@ public:
PARSEUINTOPTION(OPT_TIME, Time); PARSEUINTOPTION(OPT_TIME, Time);
PARSEUINTOPTION(OPT_DTIME, Dtime); PARSEUINTOPTION(OPT_DTIME, Dtime);
PARSEUINTOPTION(OPT_NFRAMES, Frames); PARSEUINTOPTION(OPT_NFRAMES, Frames);
PARSEUINTOPTION(OPT_FNPADDING, FilenamePadding);
PARSEUINTOPTION(OPT_LOOPS, Loops); PARSEUINTOPTION(OPT_LOOPS, Loops);
PARSEUINTOPTION(OPT_REPEAT, Repeat); PARSEUINTOPTION(OPT_REPEAT, Repeat);
PARSEUINTOPTION(OPT_TRIES, Tries); PARSEUINTOPTION(OPT_TRIES, Tries);
@ -696,7 +693,6 @@ public:
EmberOptionEntry<uint> Time; EmberOptionEntry<uint> Time;
EmberOptionEntry<uint> Dtime; EmberOptionEntry<uint> Dtime;
EmberOptionEntry<uint> Frames; EmberOptionEntry<uint> Frames;
EmberOptionEntry<uint> FilenamePadding;
EmberOptionEntry<uint> Loops; EmberOptionEntry<uint> Loops;
EmberOptionEntry<uint> Repeat; EmberOptionEntry<uint> Repeat;
EmberOptionEntry<uint> Tries; EmberOptionEntry<uint> Tries;

View File

@ -28,6 +28,7 @@ bool EmberRender(EmberOptions& opt)
Timing t; Timing t;
bool writeSuccess = false; bool writeSuccess = false;
byte* finalImagep; byte* finalImagep;
uint padding;
size_t i, channels; size_t i, channels;
size_t strips; size_t strips;
size_t iterCount; size_t iterCount;
@ -144,6 +145,7 @@ bool EmberRender(EmberOptions& opt)
//Final setup steps before running. //Final setup steps before running.
os.imbue(std::locale("")); os.imbue(std::locale(""));
padding = uint(log10((double)embers.size())) + 1;
renderer->EarlyClip(opt.EarlyClip()); renderer->EarlyClip(opt.EarlyClip());
renderer->YAxisUp(opt.YAxisUp()); renderer->YAxisUp(opt.YAxisUp());
renderer->LockAccum(opt.LockAccum()); renderer->LockAccum(opt.LockAccum());
@ -259,10 +261,10 @@ bool EmberRender(EmberOptions& opt)
} }
else else
{ {
ostringstream ssLocal; ostringstream fnstream;
ssLocal << inputPath << opt.Prefix() << setfill('0') << setw(5) << i << opt.Suffix() << "." << opt.Format(); fnstream << inputPath << opt.Prefix() << setfill('0') << setw(padding) << i << opt.Suffix() << "." << opt.Format();
filename = ssLocal.str(); filename = fnstream.str();
} }
//TotalIterCount() is actually using ScaledQuality() which does not get reset upon ember assignment, //TotalIterCount() is actually using ScaledQuality() which does not get reset upon ember assignment,

View File

@ -1883,6 +1883,15 @@ int _tmain(int argc, _TCHAR* argv[])
//int i; //int i;
Timing t(4); Timing t(4);
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand; QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
double d = 1;
for (int i = 0; i < 10; i++)
{
cout << "log10(" << d << ") = " << std::max<uint>(1u, uint(log10(d)) + 1u) << endl;
d *= 10;
}
return 0;
//glm::vec2 solution, src[4]; //glm::vec2 solution, src[4];
//double bezT = 1, w[4]; //double bezT = 1, w[4];
//BezierPoints curvePoints[4]; //BezierPoints curvePoints[4];
@ -1957,11 +1966,11 @@ int _tmain(int argc, _TCHAR* argv[])
//cd2 = sin(cd); //cd2 = sin(cd);
t.Tic(); /*t.Tic();
TestCasting(); TestCasting();
t.Toc("TestCasting()"); t.Toc("TestCasting()");
/*t.Tic(); t.Tic();
VariationList<float> vlf; VariationList<float> vlf;
t.Toc("Creating VariationList<float>"); t.Toc("Creating VariationList<float>");