--User changes

-Clear all color curves when clicking Reset while holding down Ctrl.
 -Interpolate color curves when generating a sequence.

--Bug fixes
 -Undo a change made last year which gave the wrong color index for final xforms when generating a sequence.

--Code changes
 -No longer assume palettes are 256 elements. Can now read longer palettes.
 -Ensure OpenCL images always get written when created.
This commit is contained in:
Person
2019-04-25 22:34:09 -07:00
parent 77515aae73
commit 5f98be7336
7 changed files with 49 additions and 28 deletions

View File

@ -273,7 +273,6 @@ public:
if (UseFinalXform())//Caller wanted one and this ember has one.
{
ember.m_FinalXform = m_FinalXform;
ember.m_FinalXform.m_ColorX = T(XformCount() & 1);
}
else//Caller wanted one and this ember doesn't have one.
{
@ -779,7 +778,24 @@ public:
InterpT<&Ember<T>::m_MinRadDE>(embers, coefs, size);
InterpT<&Ember<T>::m_CurveDE>(embers, coefs, size);
InterpT<&Ember<T>::m_SpatialFilterRadius>(embers, coefs, size);
InterpX<Curves<float>, &Ember<T>::m_Curves>(embers, coefs, size);
//At this point, all of the curves at a given curve index (0 - 3) should have the same number of spline points across all embers.
for (size_t i = 0; i < embers[0].m_Curves.m_Points.size(); i++)//4 point arrays.
{
while (m_Curves.m_Points[i].size() < embers[0].m_Curves.m_Points[i].size())
m_Curves.m_Points[i].push_back(v2F(0));
for (size_t j = 0; j < embers[0].m_Curves.m_Points[i].size(); j++)//Same number of points for this curve across all embers, so just use the first one.
{
v2F x(0);
for (size_t k = 0; k < size; k++)//Iterate over all embers.
x += float(coefs[k]) * embers[k].m_Curves.m_Points[i][j];
m_Curves.m_Points[i][j] = x;
}
}
//Normally done in assignment, must manually do here.
SetProjFunc();
//An extra step needed here due to the OOD that was not needed in the original.

View File

@ -61,13 +61,13 @@ public:
{
bool aligned = true;
bool currentFinal, hasFinal = sourceEmbers[0].UseFinalXform();
size_t i, xf, currentCount, maxCount = sourceEmbers[0].XformCount();
size_t xf, currentCount, maxCount = sourceEmbers[0].XformCount();
Xform<T>* destOtherXform;
auto variationList = VariationList<T>::Instance();
//Determine the max number of xforms present in sourceEmbers.
//Also check if final xforms are used in any of them.
for (i = 1; i < count; i++)
for (size_t i = 1; i < count; i++)
{
currentCount = sourceEmbers[i].XformCount();
@ -89,19 +89,31 @@ public:
}
//Copy them using the max xform count, and do final if any had final.
for (i = 0; i < count; i++)
for (size_t i = 0; i < count; i++)
destEmbers[i] = sourceEmbers[i].Copy(maxCount, hasFinal);
if (hasFinal)
maxCount++;
std::array<size_t, 4> maxCurvePoints = { 0, 0, 0, 0 };
//Find the maximum number of points for each curve type in all curves.
for (size_t e = 0; e < count; e++)
for (size_t j = 0; j < sourceEmbers[0].m_Curves.m_Points.size(); j++)//Should always be 4 for every ember.
maxCurvePoints[j] = std::max(maxCurvePoints[j], sourceEmbers[e].m_Curves.m_Points[j].size());
//Check to see if there's a parametric variation present in one xform
//but not in an aligned xform. If this is the case, use the parameters
//from the xform with the variation as the defaults for the blank one.
//All embers will have the same number of xforms at this point.
for (i = 0; i < count; i++)
for (size_t i = 0; i < count; i++)
{
intmax_t ii;
destEmbers[i].m_Curves = sourceEmbers[i].m_Curves;
for (size_t j = 0; j < sourceEmbers[0].m_Curves.m_Points.size(); j++)//Should always be 4 for every ember.
while (destEmbers[i].m_Curves.m_Points[j].size() < maxCurvePoints[j])
destEmbers[i].m_Curves.m_Points[j].push_back(sourceEmbers[i].m_Curves.m_Points[j].back());
for (xf = 0; xf < maxCount; xf++)//This will include both normal xforms and the final.
{

View File

@ -1733,25 +1733,18 @@ void Renderer<T, bucketT>::ComputeCurves()
{
if (m_CurvesSet)
{
//Timing t;
auto st = m_Csa.size();
vector<glm::tvec2<float, glm::defaultp>> vals;
vals.reserve(m_Ember.m_Curves.m_Points[0].size());
for (glm::length_t i = 0; i < m_Ember.m_Curves.m_Points.size(); i++)//Overall, r, g, b.
{
for (auto& p : m_Ember.m_Curves.m_Points[i])
vals.push_back(p);
if (!m_Ember.m_Curves.m_Points[i].empty())
{
Spline<float> spline(m_Ember.m_Curves.m_Points[i]);//Will internally sort.
Spline<float> spline(vals);//Will internally sort.
for (glm::length_t j = 0; j < st; j++)
m_Csa[j][i] = spline.Interpolate(j * ONE_OVER_CURVES_LENGTH_M1);
vals.clear();
for (glm::length_t j = 0; j < st; j++)
m_Csa[j][i] = spline.Interpolate(j * ONE_OVER_CURVES_LENGTH_M1);
}
}
//t.Toc("ComputeCurves");
}
}