mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-02 14:26:17 -04:00
--Code changes
-Bump to version 1.0.0.3 -Remove all code for opacity adjustment, it's no longer needed. -Small optimization on accumulating to the histogram on the CPU.
This commit is contained in:
@ -37,7 +37,7 @@ static void sincos(float x, float* s, float* c)
|
||||
|
||||
namespace EmberNs
|
||||
{
|
||||
#define EMBER_VERSION "1.0.0.2"
|
||||
#define EMBER_VERSION "1.0.0.3"
|
||||
#define EPS6 T(1e-6)
|
||||
#define EPS std::numeric_limits<T>::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
|
||||
#define ISAAC_SIZE 4
|
||||
|
@ -213,7 +213,7 @@ protected:
|
||||
firstBadPoint.m_Y = rand.Frand11<T>();
|
||||
firstBadPoint.m_Z = 0;
|
||||
firstBadPoint.m_ColorX = point->m_ColorX;
|
||||
firstBadPoint.m_VizAdjusted = point->m_VizAdjusted;
|
||||
firstBadPoint.m_Opacity = point->m_Opacity;
|
||||
xformIndex = NextXformFromIndex(rand.Rand());
|
||||
|
||||
if (!xforms[xformIndex].Apply(&firstBadPoint, point, rand))
|
||||
@ -245,9 +245,9 @@ protected:
|
||||
{
|
||||
if (IsClose<T>(ember.FinalXform()->m_Opacity, 1) || rand.Frand01<T>() < ember.FinalXform()->m_Opacity)
|
||||
{
|
||||
T tempVizAdjusted = tempPoint.m_VizAdjusted;
|
||||
T tempOpacity = tempPoint.m_Opacity;
|
||||
ember.NonConstFinalXform()->Apply(&tempPoint, sample, rand);
|
||||
sample->m_VizAdjusted = tempVizAdjusted;
|
||||
sample->m_Opacity = tempOpacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -433,7 +433,7 @@ public:
|
||||
firstBadPoint.m_Y = rand.Frand11<T>();
|
||||
firstBadPoint.m_Z = 0;
|
||||
firstBadPoint.m_ColorX = point->m_ColorX;
|
||||
firstBadPoint.m_VizAdjusted = point->m_VizAdjusted;
|
||||
firstBadPoint.m_Opacity = point->m_Opacity;
|
||||
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
|
||||
|
||||
if (!xforms[xformIndex].Apply(&firstBadPoint, point, rand))
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
m_Z = point.m_Z;
|
||||
m_ColorX = point.m_ColorX;
|
||||
//m_ColorY = point.m_ColorY;
|
||||
m_VizAdjusted = point.m_VizAdjusted;
|
||||
m_Opacity = point.m_Opacity;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
T m_Z = 0;
|
||||
T m_ColorX = 0;
|
||||
//T m_ColorY;
|
||||
T m_VizAdjusted = 1;
|
||||
T m_Opacity = 1;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -1516,21 +1516,21 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
|
||||
{
|
||||
Point<T> p(samples[i]);//Slightly faster to cache this.
|
||||
|
||||
if (Rotate() != 0)
|
||||
if (p.m_Opacity != 0)
|
||||
{
|
||||
T p00 = p.m_X - CenterX();
|
||||
T p11 = p.m_Y - m_Ember.m_RotCenterY;
|
||||
p.m_X = (p00 * m_RotMat.A()) + (p11 * m_RotMat.B()) + CenterX();
|
||||
p.m_Y = (p00 * m_RotMat.D()) + (p11 * m_RotMat.E()) + m_Ember.m_RotCenterY;
|
||||
}
|
||||
if (Rotate() != 0)
|
||||
{
|
||||
T p00 = p.m_X - CenterX();
|
||||
T p11 = p.m_Y - m_Ember.m_RotCenterY;
|
||||
p.m_X = (p00 * m_RotMat.A()) + (p11 * m_RotMat.B()) + CenterX();
|
||||
p.m_Y = (p00 * m_RotMat.D()) + (p11 * m_RotMat.E()) + m_Ember.m_RotCenterY;
|
||||
}
|
||||
|
||||
//Checking this first before converting gives better performance than converting and checking a single value, which the original did.
|
||||
//Second, an interesting optimization observation is that when keeping the bounds vars within m_CarToRas and calling its InBounds() member function,
|
||||
//rather than here as members, about a 7% speedup is achieved. This is possibly due to the fact that data from m_CarToRas is accessed
|
||||
//right after the call to Convert(), so some caching efficiencies get realized.
|
||||
if (m_CarToRas.InBounds(p))
|
||||
{
|
||||
if (p.m_VizAdjusted != 0)
|
||||
//Checking this first before converting gives better performance than converting and checking a single value, which the original did.
|
||||
//Second, an interesting optimization observation is that when keeping the bounds vars within m_CarToRas and calling its InBounds() member function,
|
||||
//rather than here as members, about a 7% speedup is achieved. This is possibly due to the fact that data from m_CarToRas is accessed
|
||||
//right after the call to Convert(), so some caching efficiencies get realized.
|
||||
if (m_CarToRas.InBounds(p))
|
||||
{
|
||||
m_CarToRas.Convert(p, histIndex);
|
||||
|
||||
@ -1563,7 +1563,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
|
||||
auto cifm1 = bucketT(1) - colorIndexFrac;
|
||||
|
||||
//Loops are unrolled to allow auto vectorization.
|
||||
if (p.m_VizAdjusted == 1)
|
||||
if (p.m_Opacity == 1)
|
||||
{
|
||||
hist[0] += (pal[0] * cifm1) + (pal2[0] * colorIndexFrac);
|
||||
hist[1] += (pal[1] * cifm1) + (pal2[1] * colorIndexFrac);
|
||||
@ -1572,7 +1572,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
|
||||
}
|
||||
else
|
||||
{
|
||||
auto va = bucketT(p.m_VizAdjusted);
|
||||
auto va = bucketT(p.m_Opacity);
|
||||
hist[0] += ((pal[0] * cifm1) + (pal2[0] * colorIndexFrac)) * va;
|
||||
hist[1] += ((pal[1] * cifm1) + (pal2[1] * colorIndexFrac)) * va;
|
||||
hist[2] += ((pal[2] * cifm1) + (pal2[2] * colorIndexFrac)) * va;
|
||||
@ -1589,17 +1589,17 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
|
||||
{
|
||||
Point<T> p(samples[i]);//Slightly faster to cache this.
|
||||
|
||||
if (Rotate() != 0)
|
||||
if (p.m_Opacity != 0)
|
||||
{
|
||||
T p00 = p.m_X - CenterX();
|
||||
T p11 = p.m_Y - m_Ember.m_RotCenterY;
|
||||
p.m_X = (p00 * m_RotMat.A()) + (p11 * m_RotMat.B()) + CenterX();
|
||||
p.m_Y = (p00 * m_RotMat.D()) + (p11 * m_RotMat.E()) + m_Ember.m_RotCenterY;
|
||||
}
|
||||
if (Rotate() != 0)
|
||||
{
|
||||
T p00 = p.m_X - CenterX();
|
||||
T p11 = p.m_Y - m_Ember.m_RotCenterY;
|
||||
p.m_X = (p00 * m_RotMat.A()) + (p11 * m_RotMat.B()) + CenterX();
|
||||
p.m_Y = (p00 * m_RotMat.D()) + (p11 * m_RotMat.E()) + m_Ember.m_RotCenterY;
|
||||
}
|
||||
|
||||
if (m_CarToRas.InBounds(p))
|
||||
{
|
||||
if (p.m_VizAdjusted != 0)
|
||||
if (m_CarToRas.InBounds(p))
|
||||
{
|
||||
m_CarToRas.Convert(p, histIndex);
|
||||
|
||||
@ -1609,7 +1609,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
|
||||
bucketT* __restrict hist = glm::value_ptr(m_HistBuckets[histIndex]);//Vectorizer can't tell these point to different locations.
|
||||
const bucketT* __restrict pal = glm::value_ptr(palette->m_Entries[intColorIndex]);
|
||||
|
||||
if (p.m_VizAdjusted == 1)
|
||||
if (p.m_Opacity == 1)
|
||||
{
|
||||
hist[0] += pal[0];
|
||||
hist[1] += pal[1];
|
||||
@ -1618,7 +1618,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
|
||||
}
|
||||
else
|
||||
{
|
||||
auto va = bucketT(p.m_VizAdjusted);
|
||||
auto va = bucketT(p.m_Opacity);
|
||||
hist[0] += pal[0] * va;
|
||||
hist[1] += pal[1] * va;
|
||||
hist[2] += pal[2] * va;
|
||||
|
@ -474,7 +474,7 @@ public:
|
||||
m_ParentEmber = nullptr;
|
||||
m_ColorSpeedCache = 0;
|
||||
m_OneMinusColorCache = 0;
|
||||
m_VizAdjusted = 0;
|
||||
m_Opacity = 0;
|
||||
m_Animate = 0;
|
||||
m_Wind[0] = 0;
|
||||
m_Wind[1] = 0;
|
||||
@ -482,7 +482,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compute color cache values: color speed, one minus color speed and adjusted visibility.
|
||||
/// Compute color cache values: color speed and one minus color speed.
|
||||
/// </summary>
|
||||
void CacheColorVals()
|
||||
{
|
||||
@ -491,7 +491,6 @@ public:
|
||||
//m_OneMinusColorCache = (1 + m_ColorSpeed) / 2;
|
||||
m_ColorSpeedCache = m_ColorSpeed * m_ColorX;//Flam3 style.
|
||||
m_OneMinusColorCache = T(1.0) - m_ColorSpeed;
|
||||
m_VizAdjusted = AdjustOpacityPercentage(m_Opacity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -598,7 +597,7 @@ public:
|
||||
//to the histogram. Calculate this value by interpolating between the index value of the
|
||||
//last iteration with the one specified in this xform. Note that some cached values are used
|
||||
//to reduce the amount of processing.
|
||||
outPoint->m_VizAdjusted = m_VizAdjusted;
|
||||
outPoint->m_Opacity = m_Opacity;
|
||||
iterHelper.m_Color.x = outPoint->m_ColorX = m_ColorSpeedCache + (m_OneMinusColorCache * inPoint->m_ColorX);
|
||||
|
||||
if (m_HasPreOrRegularVars)
|
||||
@ -788,7 +787,6 @@ public:
|
||||
size_t PostVariationCount() const { return m_PostVariations.size(); }
|
||||
size_t TotalVariationCount() const { return PreVariationCount() + VariationCount() + PostVariationCount(); }
|
||||
bool Empty() const { return TotalVariationCount() == 0 && m_Affine.IsID(); }//Use this instead of padding like the original did.
|
||||
T VizAdjusted() const { return m_VizAdjusted; }
|
||||
T ColorSpeedCache() const { return m_ColorSpeedCache; }
|
||||
T OneMinusColorCache() const { return m_OneMinusColorCache; }
|
||||
const vector<T>& XaosVec() const { return m_Xaos; }
|
||||
@ -1133,7 +1131,6 @@ public:
|
||||
ss << "\nColor Speed: " << m_ColorSpeed;
|
||||
ss << "\nAnimate: " << m_Animate;
|
||||
ss << "\nOpacity: " << m_Opacity;
|
||||
ss << "\nViz Adjusted: " << m_VizAdjusted;
|
||||
ss << "\nWind: " << m_Wind[0] << ", " << m_Wind[1];
|
||||
ss << "\nMotion Frequency: " << m_MotionFreq;
|
||||
ss << "\nMotion Func: " << m_MotionFunc;
|
||||
@ -1165,7 +1162,6 @@ public:
|
||||
|
||||
private:
|
||||
bool m_HasPreOrRegularVars;//Whethere there are any pre or regular variations present.
|
||||
T m_VizAdjusted;//Adjusted visibility for better transitions.
|
||||
|
||||
public:
|
||||
//Color coordinates for this function. This is the index into the palette used to look up a color and add to the histogram for each iter.
|
||||
@ -1237,20 +1233,6 @@ private:
|
||||
func(m_PostVariations, keepGoing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust opacity.
|
||||
/// </summary>
|
||||
/// <param name="in">The opacity to adjust, range 0-1.</param>
|
||||
/// <returns>The adjusted opacity</returns>
|
||||
static T AdjustOpacityPercentage(T in)
|
||||
{
|
||||
return in;
|
||||
/* if (in == 0)
|
||||
return 0;
|
||||
else
|
||||
return std::pow(T(10.0), -std::log(T(1.0) / T(in)) / std::log(T(2)));*/
|
||||
}
|
||||
|
||||
vector<T> m_Xaos;//Xaos vector which affects the probability that this xform is chosen. Usually empty.
|
||||
Ember<T>* m_ParentEmber;//The parent ember that contains this xform.
|
||||
bool m_NeedPrecalcSumSquares;//Whether any variation uses the precalc sum squares value in its calculations.
|
||||
|
Reference in New Issue
Block a user