--Bug fixes

-Attempt to fix several OpenCL build errors that were occurring on Mac.

--Code changes
 -Improve the coloring code during final accum by getting rid of the last remnants of unnecessary scaling to 255 from flam3.
 -Begin work of supporting 16bpc on the GPU.
This commit is contained in:
Person 2017-07-04 23:08:06 -07:00
parent 562ab9b01a
commit 2adf9f3ff9
16 changed files with 292 additions and 232 deletions

View File

@ -557,9 +557,9 @@ public:
static void CalcNewRgb(bucketT* cBuf, T ls, T highPow, bucketT* newRgb)
{
size_t rgbi;
T newls, lsratio;
T lsratio;
bucketT newhsv[3];
T maxa, maxc;
T maxa, maxc, newls;
T adjustedHighlight;
if (ls == 0 || (cBuf[0] == 0 && cBuf[1] == 0 && cBuf[2] == 0))
@ -573,35 +573,31 @@ public:
//Identify the most saturated channel.
maxc = std::max(std::max(cBuf[0], cBuf[1]), cBuf[2]);
maxa = ls * maxc;
newls = 1 / maxc;
//If a channel is saturated and highlight power is non-negative
//modify the color to prevent hue shift.
if (maxa > 255 && highPow >= 0)
if (maxa > 1 && highPow >= 0)
{
newls = T(255.0) / maxc;
lsratio = std::pow(newls / ls, highPow);
//Calculate the max-value color (ranged 0 - 1).
for (rgbi = 0; rgbi < 3; rgbi++)
newRgb[rgbi] = bucketT(newls) * cBuf[rgbi] / bucketT(255.0);
newRgb[rgbi] = bucketT(newls) * cBuf[rgbi];
//Reduce saturation by the lsratio.
Palette<bucketT>::RgbToHsv(newRgb, newhsv);
newhsv[1] *= bucketT(lsratio);
Palette<bucketT>::HsvToRgb(newhsv, newRgb);
for (rgbi = 0; rgbi < 3; rgbi++)
newRgb[rgbi] *= T(255.0);
}
else
{
newls = T(255.0) / maxc;
adjustedHighlight = -highPow;
if (adjustedHighlight > 1)
adjustedHighlight = 1;
if (maxa <= 255)
if (maxa <= 1)
adjustedHighlight = 1;
//Calculate the max-value color (ranged 0 - 1) interpolated with the old behavior.

View File

@ -3,6 +3,15 @@
namespace EmberNs
{
/// <summary>
/// Constructor that allocates various pieces of memory.
/// </summary>
template <typename T, typename bucketT>
Renderer<T, bucketT>::Renderer()
{
m_Csa.resize(size_t(std::pow(size_t(256), BytesPerChannel())));//Need to at least have something here so the derived RendererCL can do the initial buffer allocation.
}
/// <summary>
/// Non-virtual processing functions.
/// </summary>
@ -344,7 +353,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<byte>& finalImage, double time, s
bool accumOnly = m_ProcessAction == eProcessAction::ACCUM_ONLY;
bool resume = m_ProcessState != eProcessState::NONE;
bool newFilterAlloc;
size_t i, temporalSample = 0;
size_t temporalSample = 0;
T deTime;
auto success = eRenderStatus::RENDER_OK;
@ -636,11 +645,7 @@ AccumOnly:
CreateSpatialFilter(newFilterAlloc);
m_DensityFilterOffset = m_GutterWidth - size_t(Clamp<T>((T(m_SpatialFilter->FinalFilterWidth()) - T(Supersample())) / 2, 0, T(m_GutterWidth)));
m_CurvesSet = m_Ember.m_Curves.CurvesSet();
//Color curves must be re-calculated as well.
if (m_CurvesSet)
for (i = 0; i < COLORMAP_LENGTH; i++)
m_Csa[i] = m_Ember.m_Curves.BezierFunc(i / T(COLORMAP_LENGTH_MINUS_1)) * T(COLORMAP_LENGTH_MINUS_1);
ComputeCurves(true);//Color curves must be re-calculated as well.
if (AccumulatorToFinalImage(finalImage, finalOffset) == eRenderStatus::RENDER_OK)
{
@ -1086,13 +1091,13 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(byte* pixels, size_t
bucketT g, linRange, vibrancy;
Color<bucketT> background;
pixels += finalOffset;
PrepFinalAccumVals(background, g, linRange, vibrancy);
PrepFinalAccumVals(background, g, linRange, vibrancy);//After this, background has been scaled from 0-1 to 0-255.
//If early clip, go through the entire accumulator and perform gamma correction first.
//The original does it this way as well and it's roughly 11 times faster to do it this way than inline below with each pixel.
if (EarlyClip())
{
parallel_for(size_t(0), m_SuperRasH, size_t(1), [&] (size_t j)
parallel_for(size_t(0), m_SuperRasH, size_t(1), [&](size_t j)
{
auto rowStart = m_AccumulatorBuckets.data() + (j * m_SuperRasW);//Pull out of inner loop for optimization.
auto rowEnd = rowStart + m_SuperRasW;
@ -1150,6 +1155,8 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(byte* pixels, size_t
if (EarlyClip())
{
newBucket *= bucketT(65535);
if (m_CurvesSet)
{
CurveAdjust(newBucket.r, 1);
@ -1157,14 +1164,14 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(byte* pixels, size_t
CurveAdjust(newBucket.b, 3);
}
p16[0] = glm::uint16(Clamp<bucketT>(newBucket.r, 0, 255) * bucketT(256));
p16[1] = glm::uint16(Clamp<bucketT>(newBucket.g, 0, 255) * bucketT(256));
p16[2] = glm::uint16(Clamp<bucketT>(newBucket.b, 0, 255) * bucketT(256));
p16[0] = glm::uint16(Clamp<bucketT>(newBucket.r, 0, 65535));
p16[1] = glm::uint16(Clamp<bucketT>(newBucket.g, 0, 65535));
p16[2] = glm::uint16(Clamp<bucketT>(newBucket.b, 0, 65535));
if (doAlpha)
{
if (Transparency())
p16[3] = byte(Clamp<bucketT>(newBucket.a, 0, 1) * bucketT(65535.0));
p16[3] = byte(Clamp<bucketT>(newBucket.a, 0, 65535));
else
p16[3] = 65535;
}
@ -1178,6 +1185,8 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(byte* pixels, size_t
{
if (EarlyClip())
{
newBucket *= bucketT(255);
if (m_CurvesSet)
{
CurveAdjust(newBucket.r, 1);
@ -1185,14 +1194,14 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(byte* pixels, size_t
CurveAdjust(newBucket.b, 3);
}
pixels[pixelsRowStart] = byte(Clamp<bucketT>(newBucket.r, 0, 255));
pixels[pixelsRowStart] = byte(Clamp<bucketT>(newBucket.r, 0, 255));
pixels[pixelsRowStart + 1] = byte(Clamp<bucketT>(newBucket.g, 0, 255));
pixels[pixelsRowStart + 2] = byte(Clamp<bucketT>(newBucket.b, 0, 255));
if (doAlpha)
{
if (Transparency())
pixels[pixelsRowStart + 3] = byte(Clamp<bucketT>(newBucket.a, 0, 1) * bucketT(255.0));
pixels[pixelsRowStart + 3] = byte(Clamp<bucketT>(newBucket.a, 0, 255));
else
pixels[pixelsRowStart + 3] = 255;
}
@ -1484,9 +1493,9 @@ void Renderer<T, bucketT>::PrepFinalAccumVals(Color<bucketT>& background, bucket
g = 1 / ClampGte<bucketT>(gamma / vibGamCount, bucketT(0.01));//Ensure a divide by zero doesn't occur.
linRange = GammaThresh();
vibrancy /= vibGamCount;
background.x = (IsNearZero(m_Background.r) ? bucketT(m_Ember.m_Background.r) : m_Background.r) / (vibGamCount / bucketT(256.0));//Background is [0, 1].
background.y = (IsNearZero(m_Background.g) ? bucketT(m_Ember.m_Background.g) : m_Background.g) / (vibGamCount / bucketT(256.0));
background.z = (IsNearZero(m_Background.b) ? bucketT(m_Ember.m_Background.b) : m_Background.b) / (vibGamCount / bucketT(256.0));
background.x = (IsNearZero(m_Background.r) ? bucketT(m_Ember.m_Background.r) : m_Background.r) / vibGamCount;
background.y = (IsNearZero(m_Background.g) ? bucketT(m_Ember.m_Background.g) : m_Background.g) / vibGamCount;
background.z = (IsNearZero(m_Background.b) ? bucketT(m_Ember.m_Background.b) : m_Background.b) / vibGamCount;
}
/// <summary>
@ -1684,7 +1693,7 @@ template <typename accumT>
void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket, Color<bucketT>& background, bucketT g, bucketT linRange, bucketT vibrancy, bool doAlpha, bool scale, accumT* correctedChannels)
{
bucketT alpha, ls, a, newRgb[3];//Would normally use a Color<bucketT>, but don't want to call a needless constructor every time this function is called, which is once per pixel.
static bucketT scaleVal = (numeric_limits<accumT>::max() + 1) / bucketT(256.0);
static bucketT scaleVal = numeric_limits<accumT>::max();
if (bucket.a <= 0)
{
@ -1694,7 +1703,7 @@ void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket
else
{
alpha = Palette<bucketT>::CalcAlpha(bucket.a, g, linRange);
ls = vibrancy * 255 * alpha / bucket.a;
ls = vibrancy * alpha / bucket.a;
ClampRef<bucketT>(alpha, 0, 1);
}
@ -1702,7 +1711,7 @@ void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket
for (glm::length_t rgbi = 0; rgbi < 3; rgbi++)
{
a = newRgb[rgbi] + ((1 - vibrancy) * 255 * std::pow(std::abs(bucket[rgbi]), g));//Must use abs(), else it it could be a negative value and return NAN.
a = newRgb[rgbi] + ((1 - vibrancy) * std::pow(std::abs(bucket[rgbi]), g));//Must use abs(), else it it could be a negative value and return NAN.
if (NumChannels() <= 3 || !Transparency())
{
@ -1718,14 +1727,16 @@ void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket
if (!scale)
{
correctedChannels[rgbi] = accumT(Clamp<bucketT>(a, 0, 255));//Early clip, just assign directly.
correctedChannels[rgbi] = accumT(Clamp<bucketT>(a, 0, 1.0));//Early clip, just assign directly.
}
else
{
a *= scaleVal;
if (m_CurvesSet)
CurveAdjust(a, rgbi + 1);
correctedChannels[rgbi] = accumT(Clamp<bucketT>(a, 0, 255) * scaleVal);//Final accum, multiply by 1 for 8 bpc, or 256 for 16 bpc.
correctedChannels[rgbi] = accumT(Clamp<bucketT>(a, 0, scaleVal));//Final accum, multiply by 255 for 8 bpc (0-255), or 65535 for 16 bpc (0-65535).
}
}
@ -1734,18 +1745,44 @@ void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket
if (!scale)
correctedChannels[3] = accumT(alpha);//Early clip, just assign alpha directly.
else if (Transparency())
correctedChannels[3] = accumT(alpha * numeric_limits<accumT>::max());//Final accum, 4 channels, using transparency. Scale alpha from 0-1 to 0-255 for 8 bpc or 0-65535 for 16 bpc.
correctedChannels[3] = accumT(alpha * scaleVal);//Final accum, 4 channels, using transparency. Scale alpha from 0-1 to 0-255 for 8 bpc or 0-65535 for 16 bpc.
else
correctedChannels[3] = numeric_limits<accumT>::max();//Final accum, 4 channels, but not using transparency. 255 for 8 bpc, 65535 for 16 bpc.
correctedChannels[3] = accumT(scaleVal);//Final accum, 4 channels, but not using transparency. 255 for 8 bpc, 65535 for 16 bpc.
}
}
/// <summary>
/// Setup the curve values when they are being used.
/// This will be either 255 values for bpc=8, or 65535 values for bpc=16.
/// </summary>
/// <param name="scale">Whether to scale from 0-1 to 0-255 or 0-65535</param>
template <typename T, typename bucketT>
void Renderer<T, bucketT>::CurveAdjust(bucketT& a, const glm::length_t& index)
void Renderer<T, bucketT>::ComputeCurves(bool scale)
{
size_t tempIndex = size_t(Clamp<bucketT>(a, 0, COLORMAP_LENGTH_MINUS_1));
size_t tempIndex2 = size_t(Clamp<bucketT>(m_Csa[tempIndex].x, 0, COLORMAP_LENGTH_MINUS_1));
a = std::round(m_Csa[tempIndex2][index]);
if (m_CurvesSet)
{
m_Csa.resize(size_t(std::pow(size_t(256), BytesPerChannel())));
auto st = m_Csa.size();
auto stm1 = st - 1;
T tscale = scale ? T(stm1) : T(1);
for (size_t i = 0; i < st; i++)
m_Csa[i] = m_Ember.m_Curves.BezierFunc(i / T(stm1)) * tscale;
}
}
/// <summary>
/// Apply the curve adjustment to a single channel.
/// </summary>
/// <param name="aScaled">The value of the channel to apply curve adjustment to, scaled to either 255 or 65535, depending on bpc.</param>
/// <param name="index">The index of the channel to apply curve adjustment to</param>
template <typename T, typename bucketT>
void Renderer<T, bucketT>::CurveAdjust(bucketT& aScaled, const glm::length_t& index)
{
bucketT stm1 = bucketT(m_Csa.size() - 1);
size_t tempIndex = size_t(Clamp<bucketT>(aScaled, 0, stm1));
size_t tempIndex2 = size_t(Clamp<bucketT>(m_Csa[tempIndex].x, 0, stm1));
aScaled = m_Csa[tempIndex2][index];
}
//This class had to be implemented in a cpp file because the compiler was breaking.

View File

@ -44,8 +44,7 @@ template <typename T, typename bucketT>
class EMBER_API Renderer : public RendererBase
{
public:
Renderer() = default;
Renderer();
Renderer(const Renderer<T, bucketT>& renderer) = delete;
Renderer<T, bucketT>& operator = (const Renderer<T, bucketT>& renderer) = delete;
virtual ~Renderer() = default;
@ -80,6 +79,7 @@ protected:
virtual eRenderStatus AccumulatorToFinalImage(vector<byte>& pixels, size_t finalOffset);
virtual eRenderStatus AccumulatorToFinalImage(byte* pixels, size_t finalOffset);
virtual EmberStats Iterate(size_t iterCount, size_t temporalSample);
virtual void ComputeCurves(bool scale);
public:
//Non-virtual render properties, getters and setters.
@ -189,7 +189,8 @@ protected:
unique_ptr<StandardIterator<T>> m_StandardIterator = make_unique<StandardIterator<T>>();
unique_ptr<XaosIterator<T>> m_XaosIterator = make_unique<XaosIterator<T>>();
Iterator<T>* m_Iterator = m_StandardIterator.get();
Palette<bucketT> m_Dmap, m_Csa;
Palette<bucketT> m_Dmap;
vector<tvec4<bucketT, glm::defaultp>> m_Csa;
vector<tvec4<bucketT, glm::defaultp>> m_HistBuckets;
vector<tvec4<bucketT, glm::defaultp>> m_AccumulatorBuckets;
unique_ptr<SpatialFilter<bucketT>> m_SpatialFilter;

View File

@ -237,7 +237,7 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (precalcAtanxy * M_1_PI);\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (precalcAtanxy * M1PI);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (precalcSqrtSumSquares - (real_t)(1.0));\n"
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
@ -358,7 +358,7 @@ public:
string index = ss2.str();
string weightByPI = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
ss << "\t{\n"
<< "\t\treal_t val = M_PI * precalcSqrtSumSquares;\n"
<< "\t\treal_t val = MPI * precalcSqrtSumSquares;\n"
<< "\t\treal_t r = " << weightByPI << " * precalcAtanxy;\n"
<< "\n"
<< "\t\tvOut.x = sin(val) * r;\n"
@ -600,7 +600,7 @@ public:
<< "\t\treal_t a = (real_t)(0.5) * precalcAtanxy;\n"
<< "\n"
<< "\t\tif (MwcNext(mwc) & 1)\n"
<< "\t\t a += M_PI;\n"
<< "\t\t a += MPI;\n"
<< "\n"
<< "\t\tvOut.x = r * cos(a);\n"
<< "\t\tvOut.y = r * sin(a);\n"
@ -849,7 +849,7 @@ public:
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t dx = xform->m_VariationWeights[" << varIndex << "] * exp(vIn.x - (real_t)(1.0));\n"
<< "\t\treal_t dy = M_PI * vIn.y;\n"
<< "\t\treal_t dy = MPI * vIn.y;\n"
<< "\n"
<< "\t\tvOut.x = dx * cos(dy);\n"
<< "\t\tvOut.y = dx * sin(dy);\n"
@ -931,7 +931,7 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = vIn.x * M_PI;\n"
<< "\t\treal_t a = vIn.x * MPI;\n"
<< "\t\treal_t nx = cos(a) * cosh(vIn.y);\n"
<< "\t\treal_t ny = -sin(a) * sinh(vIn.y);\n"
<< "\n"
@ -1035,7 +1035,7 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t dx = M_PI * Zeps(xform->m_C * xform->m_C);\n"
<< "\t\treal_t dx = MPI * Zeps(xform->m_C * xform->m_C);\n"
<< "\t\treal_t dy = xform->m_F;\n"
<< "\t\treal_t dx2 = (real_t)(0.5) * dx;\n"
<< "\t\treal_t a = precalcAtanxy + ((fmod(precalcAtanxy + dy, dx) > dx2) ? -dx2 : dx2);\n"
@ -2320,7 +2320,7 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t angle = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "] * M_PI;\n"
<< "\t\treal_t angle = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "] * MPI;\n"
<< "\t\treal_t sinr = sin(angle);\n"
<< "\t\treal_t cosr = cos(angle);\n"
<< "\n"
@ -2420,7 +2420,7 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t ang = xform->m_VariationWeights[" << varIndex << "] * MwcNext01(mwc) * M_PI;\n"
<< "\t\treal_t ang = xform->m_VariationWeights[" << varIndex << "] * MwcNext01(mwc) * MPI;\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares);\n"
<< "\t\treal_t tanr = xform->m_VariationWeights[" << varIndex << "] * tan(ang) * r;\n"
<< "\n"
@ -2563,7 +2563,7 @@ public:
<< "\t\t diff = -(real_t)(30.0);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x * diff;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (diff - sinr * M_PI);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (diff - sinr * MPI);\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
@ -2649,7 +2649,7 @@ public:
<< "\t\treal_t t = " << rotTimesPi << " * (vIn.x + vIn.y);\n"
<< "\t\treal_t sinr = sin(t);\n"
<< "\t\treal_t cosr = cos(t);\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * precalcAtanxy / M_PI;\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * precalcAtanxy / MPI;\n"
<< "\n"
<< "\t\tvOut.x = (sinr + " << cosAdd << ") * r;\n"
<< "\t\tvOut.y = (cosr + " << sinAdd << ") * r;\n"
@ -2749,7 +2749,7 @@ public:
string pm4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
string pNeg1N1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t theta = " << pm4 << " * precalcAtanyx + M_PI_4;\n"
<< "\t\treal_t theta = " << pm4 << " * precalcAtanyx + MPI4;\n"
<< "\t\treal_t t1 = fabs(cos(theta));\n"
<< "\t\tt1 = pow(t1, " << n2 << ");\n"
<< "\t\treal_t t2 = fabs(sin(theta));\n"
@ -3153,10 +3153,10 @@ public:
<< "\t\treal_t ps = " << s << ";\n"
<< "\t\treal_t y = (real_t)(0.5) * atan2((real_t)(2.0) * vIn.y, x2y2 - (real_t)(1.0)) + ps;\n"
<< "\n"
<< "\t\tif (y > M_PI_2)\n"
<< "\t\t y = -M_PI_2 + fmod(y + M_PI_2, M_PI);\n"
<< "\t\telse if (y < -M_PI_2)\n"
<< "\t\t y = M_PI_2 - fmod(M_PI_2 - y, M_PI);\n"
<< "\t\tif (y > MPI2)\n"
<< "\t\t y = -MPI2 + fmod(y + MPI2, MPI);\n"
<< "\t\telse if (y < -MPI2)\n"
<< "\t\t y = MPI2 - fmod(MPI2 - y, MPI);\n"
<< "\n"
<< "\t\treal_t f = t + x2;\n"
<< "\t\treal_t g = t - x2;\n"
@ -4918,7 +4918,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t r = precalcSqrtSumSquares;\n"
<< "\t\treal_t a = precalcAtanyx + " << swirl << " * r;\n"
<< "\t\treal_t c = floor((" << count << " * a + M_PI) * M_1_PI * (real_t)(0.5));\n"
<< "\t\treal_t c = floor((" << count << " * a + MPI) * M1PI * (real_t)(0.5));\n"
<< "\n"
<< "\t\ta = a * " << compFac << " + c * " << angle << ";\n"
<< "\t\tr = xform->m_VariationWeights[" << varIndex << "] * (r + " << hole << ");\n"
@ -5005,7 +5005,7 @@ public:
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares, " << cn << ");\n"
<< "\t\tint tRand = (int)(" << rn << " * MwcNext01(mwc));\n"
<< "\t\treal_t a = (precalcAtanyx + M_2PI * tRand) / " << power << ";\n"
<< "\t\treal_t c = floor((" << count << " * a + M_PI) * M_1_PI * (real_t)(0.5));\n"
<< "\t\treal_t c = floor((" << count << " * a + MPI) * M1PI * (real_t)(0.5));\n"
<< "\n"
<< "\t\ta = a * " << cf << " + c * " << angle << ";\n"
<< "\t\tvOut.x = r * cos(a);\n"
@ -5095,7 +5095,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t r = (real_t)(1.0) / Zeps(precalcSqrtSumSquares);\n"
<< "\t\treal_t a = precalcAtanyx + " << swirl << " * r;\n"
<< "\t\treal_t c = floor((" << count << " * a + M_PI) * " << c12pi << "); \n"
<< "\t\treal_t c = floor((" << count << " * a + MPI) * " << c12pi << "); \n"
<< "\n"
<< "\t\ta = a * " << compfac << " + c * " << angle << ";\n"
<< "\t\treal_t temp = xform->m_VariationWeights[" << varIndex << "] * (r + " << hole << ");\n"

View File

@ -372,7 +372,7 @@ public:
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * side;\n"
<< "\t\treal_t val = M_PI_4 * perimeter / side - M_PI_4;\n"
<< "\t\treal_t val = MPI4 * perimeter / side - MPI4;\n"
<< "\t\treal_t sina = sin(val);\n"
<< "\t\treal_t cosa = cos(val);\n"
<< "\n"
@ -1108,7 +1108,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t angle = MwcNext01(mwc) * M_2PI;\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - (real_t)(2.0));\n"
<< "\t\treal_t angle2 = MwcNext01(mwc) * M_PI;\n"
<< "\t\treal_t angle2 = MwcNext01(mwc) * MPI;\n"
<< "\t\treal_t sina = sin(angle);\n"
<< "\t\treal_t cosa = cos(angle);\n"
<< "\t\treal_t sinb = sin(angle2);\n"
@ -1710,7 +1710,7 @@ public:
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t r = " << vvar4pi << " * side + " << hole << ";\n"
<< "\t\treal_t val = M_PI_4 * perimeter / side - M_PI_4;\n"
<< "\t\treal_t val = MPI4 * perimeter / side - MPI4;\n"
<< "\n"
<< "\t\tvOut.x = r * cos(val);\n"
<< "\t\tvOut.y = r * sin(val);\n"
@ -1818,7 +1818,7 @@ public:
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (side + " << hole << ");\n"
<< "\t\treal_t val = M_PI_4 * perimeter / side - M_PI_4;\n"
<< "\t\treal_t val = MPI4 * perimeter / side - MPI4;\n"
<< "\n"
<< "\t\tvOut.x = r * cos(val);\n"
<< "\t\tvOut.y = r * sin(val);\n"
@ -2171,7 +2171,7 @@ public:
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = M_2PI / (precalcSqrtSumSquares + 1);\n"
<< "\t\treal_t r = (precalcAtanyx * M_1_PI + 1) * (real_t)(0.5);\n"
<< "\t\treal_t r = (precalcAtanyx * M1PI + 1) * (real_t)(0.5);\n"
<< "\t\treal_t s = sin(a);\n"
<< "\t\treal_t c = cos(a);\n"
<< "\n"
@ -2223,11 +2223,11 @@ public:
<< "\t\treal_t temp = vIn.y * " << natLog << ";\n"
<< "\t\treal_t snum1 = sin(temp);\n"
<< "\t\treal_t cnum1 = cos(temp);\n"
<< "\t\ttemp = (vIn.x * M_PI + vIn.y * " << natLog << ") * -(real_t)(1.0);\n"
<< "\t\ttemp = (vIn.x * MPI + vIn.y * " << natLog << ") * -(real_t)(1.0);\n"
<< "\t\treal_t snum2 = sin(temp);\n"
<< "\t\treal_t cnum2 = cos(temp);\n"
<< "\t\treal_t eradius1 = exp(vIn.x * " << natLog << ");\n"
<< "\t\treal_t eradius2 = exp((vIn.x * " << natLog << " - vIn.y * M_PI) * -(real_t)(1.0));\n"
<< "\t\treal_t eradius2 = exp((vIn.x * " << natLog << " - vIn.y * MPI) * -(real_t)(1.0));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * cnum1 - eradius2 * cnum2) * " << five << ";\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n"
@ -2298,11 +2298,11 @@ public:
<< "\t\treal_t temp = vIn.y * " << natLog << ";\n"
<< "\t\treal_t snum1 = sin(temp);\n"
<< "\t\treal_t cnum1 = cos(temp);\n"
<< "\t\ttemp = (vIn.x * M_PI + vIn.y * " << natLog << ") * -1;\n"
<< "\t\ttemp = (vIn.x * MPI + vIn.y * " << natLog << ") * -1;\n"
<< "\t\treal_t snum2 = sin(temp);\n"
<< "\t\treal_t cnum2 = cos(temp);\n"
<< "\t\treal_t eradius1 = " << sc << " * exp(" << sc2 << " * (vIn.x * " << natLog << "));\n"
<< "\t\treal_t eradius2 = " << sc << " * exp(" << sc2 << " * ((vIn.x * " << natLog << " - vIn.y * M_PI) * -1));\n"
<< "\t\treal_t eradius2 = " << sc << " * exp(" << sc2 << " * ((vIn.x * " << natLog << " - vIn.y * MPI) * -1));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * cnum1 - eradius2 * cnum2) * " << five << ";\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n"
@ -2647,7 +2647,7 @@ public:
string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string inside = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t r, delta = pow(precalcAtanyx / (real_t)M_PI + 1, " << a << ");\n"
<< "\t\treal_t r, delta = pow(precalcAtanyx / MPI + 1, " << a << ");\n"
<< "\n"
<< "\t\tif (" << inside << " != 0)\n"
<< "\t\t r = xform->m_VariationWeights[" << varIndex << "] * delta / (precalcSqrtSumSquares + delta);\n"
@ -3310,7 +3310,7 @@ public:
string index = ss2.str();
string v = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
ss << "\t{\n"
<< "\t\treal_t a = M_PI / (precalcSqrtSumSquares + 1);\n"
<< "\t\treal_t a = MPI / (precalcSqrtSumSquares + 1);\n"
<< "\t\treal_t s = sin(a);\n"
<< "\t\treal_t c = cos(a);\n"
<< "\t\treal_t r = precalcAtanyx * " << v << ";\n"

View File

@ -34,7 +34,7 @@ public:
string index = ss2.str();
string effect = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t temp = 1 / Zeps(cos(vIn.y)) + " << effect << " * M_PI;\n"
<< "\t\treal_t temp = 1 / Zeps(cos(vIn.y)) + " << effect << " * MPI;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (tanh(vIn.x) * temp);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (tanh(vIn.y) * temp);\n"
@ -965,7 +965,7 @@ public:
<< "\n"
<< "\t\tz *= sqrt(MwcNext01(mwc));\n"
<< "\n"
<< "\t\treal_t temp = angle - M_PI_2;\n"
<< "\t\treal_t temp = angle - MPI2;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * z * cos(temp);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * z * sin(temp);\n"
@ -1035,7 +1035,7 @@ public:
<< "\t\treal_t ang = MwcNext01(mwc) * M_2PI;\n"
<< "\t\treal_t s = sin(ang);\n"
<< "\t\treal_t c = cos(ang);\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (" << power << " == 1 ? acos(MwcNext01(mwc) * 2 - 1) / M_PI : acos(exp(log(MwcNext01(mwc)) * " << power << ") * 2 - 1) / M_PI);\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (" << power << " == 1 ? acos(MwcNext01(mwc) * 2 - 1) / MPI : acos(exp(log(MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
<< "\n"
<< "\t\tvOut.x = r * c;\n"
<< "\t\tvOut.y = r * s;\n"
@ -1206,7 +1206,7 @@ public:
string workPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t xang = (precalcAtanyx + M_PI) / " << alpha << ";\n"
<< "\t\treal_t xang = (precalcAtanyx + MPI) / " << alpha << ";\n"
<< "\n"
<< "\t\txang = (xang - (int) xang) * " << alpha << ";\n"
<< "\t\txang = cos((xang < " << alpha << " / 2) ? xang : " << alpha << " - xang);\n"
@ -1302,7 +1302,7 @@ public:
string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t xang = (precalcAtanyx + M_3PI + " << alpha << " / 2) / " << alpha << ";\n"
<< "\t\treal_t zang = ((xang - (int)xang) * " << width << " + (int)xang) * " << alpha << " - M_PI - " << alpha << " / 2 * " << width << ";\n"
<< "\t\treal_t zang = ((xang - (int)xang) * " << width << " + (int)xang) * " << alpha << " - MPI - " << alpha << " / 2 * " << width << ";\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares * cos(zang);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares * sin(zang);\n"
@ -1977,7 +1977,7 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t e = 1 / precalcSumSquares + SQR(M_2_PI);\n"
<< "\t\treal_t e = 1 / precalcSumSquares + SQR(M2PI);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (xform->m_VariationWeights[" << varIndex << "] / precalcSumSquares * vIn.x / e);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (xform->m_VariationWeights[" << varIndex << "] / precalcSumSquares * vIn.y / e);\n"
@ -2096,7 +2096,7 @@ public:
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t d = precalcSumSquares + SQR(tempTz);\n"
<< "\t\treal_t e = 1 / d + SQR(M_2_PI);\n"
<< "\t\treal_t e = 1 / d + SQR(M2PI);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (xform->m_VariationWeights[" << varIndex << "] / d * vIn.x / e);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (xform->m_VariationWeights[" << varIndex << "] / d * vIn.y / e);\n"
@ -2208,7 +2208,7 @@ public:
<< "\t\tif (a < 0)\n"
<< "\t\t a += M_2PI;\n"
<< "\n"
<< "\t\treal_t p = 4 * precalcSqrtSumSquares * a * M_1_PI;\n"
<< "\t\treal_t p = 4 * precalcSqrtSumSquares * a * M1PI;\n"
<< "\n"
<< "\t\tif (p <= 1 * precalcSqrtSumSquares)\n"
<< "\t\t{\n"
@ -3258,7 +3258,7 @@ public:
string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y)));\n"
<< "\t\treal_t sigma = M_PI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n"
<< "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n"
<< "\n"
<< "\t\tif (tau < " << radius << " && -tau < " << radius << ")\n"
<< "\t\t tau = fmod(tau + " << radius << " + " << dist << " * " << radius << ", (real_t)(2.0) * " << radius << ") - " << radius << ";\n"
@ -3326,7 +3326,7 @@ public:
string out = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y)));\n"
<< "\t\treal_t sigma = M_PI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n"
<< "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n"
<< "\n"
<< "\t\tsigma = sigma + tau * " << out << " + " << in << " / tau;\n"
<< "\n"
@ -3401,7 +3401,7 @@ public:
string split = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y))) / " << power << " + " << move << ";\n"
<< "\t\treal_t sigma = M_PI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x) + " << rotate << ";\n"
<< "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x) + " << rotate << ";\n"
<< "\n"
<< "\t\tsigma = sigma / " << power << " + M_2PI / " << power << " * floor(MwcNext01(mwc) * " << power << ");\n"
<< "\n"
@ -3487,7 +3487,7 @@ public:
string piCn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t tau = (real_t)(0.5) * (log(Sqr(vIn.x + (real_t)(1.0)) + SQR(vIn.y)) - log(Sqr(vIn.x - (real_t)(1.0)) + SQR(vIn.y)));\n"
<< "\t\treal_t sigma = M_PI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n"
<< "\t\treal_t sigma = MPI - atan2(vIn.y, vIn.x + (real_t)(1.0)) - atan2(vIn.y, (real_t)(1.0) - vIn.x);\n"
<< "\t\tint alt = (int)(sigma * " << cnPi << ");\n"
<< "\n"
<< "\t\tif ((alt & 1) == 0)\n"
@ -4339,7 +4339,7 @@ public:
<< "\t\tif (vIn.y < 0)\n"
<< "\t\t nu *= -1;\n"
<< "\n"
<< "\t\tnu = fmod(nu + " << rotate << " + M_PI, M_2PI) - M_PI;\n"
<< "\t\tnu = fmod(nu + " << rotate << " + MPI, M_2PI) - MPI;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * xmax * cos(nu);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sqrt(xmax - 1) * sqrt(xmax + 1) * sin(nu);\n"
@ -4428,12 +4428,12 @@ public:
<< "\t\t nu *= -1;\n"
<< "\n"
<< "\t\tmu *= " << scale << ";\n"
<< "\t\tnu = fmod(fmod(" << scale << " * (nu + M_PI + " << angle << "), M_2PI * " << scale << ") - " << angle << " - " << scale << " * M_PI, M_2PI);\n"
<< "\t\tnu = fmod(fmod(" << scale << " * (nu + MPI + " << angle << "), M_2PI * " << scale << ") - " << angle << " - " << scale << " * MPI, M_2PI);\n"
<< "\n"
<< "\t\tif (nu > M_PI)\n"
<< "\t\tif (nu > MPI)\n"
<< "\t\t nu -= M_2PI;\n"
<< "\n"
<< "\t\tif (nu < -M_PI)\n"
<< "\t\tif (nu < -MPI)\n"
<< "\t\t nu += M_2PI;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n"

View File

@ -3053,7 +3053,7 @@ public:
"\n"
"real_t Interference2Tri(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
"{\n"
" return a * 2 * pow(fabs(asin(cos(b * x + c - (real_t)M_PI_2))) * (real_t)M_1_PI, p);\n"
" return a * 2 * pow(fabs(asin(cos(b * x + c - MPI2))) * M1PI, p);\n"
"}\n"
"\n"
"real_t Interference2Squ(real_t a, real_t b, real_t c, real_t p, real_t x)\n"

View File

@ -2306,11 +2306,11 @@ public:
ostringstream ss;
intmax_t varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = M_PI / (precalcSqrtSumSquares + 1);\n"
<< "\t\treal_t r = precalcAtanyx * M_1_PI;\n"
<< "\t\treal_t a = MPI / (precalcSqrtSumSquares + 1);\n"
<< "\t\treal_t r = precalcAtanyx * M1PI;\n"
<< "\n"
<< "\t\tif (r > 0)\n"
<< "\t\t a = M_PI - a;\n"
<< "\t\t a = MPI - a;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * r * cos(a);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * sin(a);\n"
@ -2621,7 +2621,7 @@ public:
<< "\t\t case 2:\n"
<< "\t\t {\n"
<< "\t\t real_t sigma = dist * randy * M_2PI;\n"
<< "\t\t real_t phi = dist * randz * M_PI;\n"
<< "\t\t real_t phi = dist * randz * MPI;\n"
<< "\t\t real_t rad = dist * randx;\n"
<< "\t\t real_t sigmas = sin(sigma);\n"
<< "\t\t real_t sigmac = cos(sigma);\n"
@ -2816,7 +2816,7 @@ public:
<< "\t\tcase 0:\n"
<< "\t\t {\n"
<< "\t\t real_t sigma = dist * randy * M_2PI;\n"
<< "\t\t real_t phi = dist * randz * M_PI;\n"
<< "\t\t real_t phi = dist * randz * MPI;\n"
<< "\t\t real_t rad = dist * randx;\n"
<< "\t\t real_t sigmas = sin(sigma);\n"
<< "\t\t real_t sigmac = cos(sigma);\n"

View File

@ -2112,9 +2112,9 @@ public:
"\t\t z = 2 / pow(rad, " << exponentZ << ") - 1;\n"
"\t\t\n"
"\t\t if (" << exponentZ << " <= 2)\n"
"\t\t angZ = M_PI - acos((z / (SQR(x) + SQR(y) + SQR(z))));\n"
"\t\t angZ = MPI - acos((z / (SQR(x) + SQR(y) + SQR(z))));\n"
"\t\t else\n"
"\t\t angZ = M_PI - atan2(Sqr(SQR(x) + SQR(y)), z);\n"
"\t\t angZ = MPI - atan2(Sqr(SQR(x) + SQR(y)), z);\n"
"\t\t}\n"
"\t\telse\n"
"\t\t{\n"
@ -2136,8 +2136,8 @@ public:
"\t\t }\n"
"\t\t else\n"
"\t\t {\n"
"\t\t angTmp = (M_PI - angZ) / Zeps(" << angHoleComp << " * " << angHoleTemp << " - M_PI_2);\n"
"\t\t angZ -= M_PI_2;\n"
"\t\t angTmp = (MPI - angZ) / Zeps(" << angHoleComp << " * " << angHoleTemp << " - MPI2);\n"
"\t\t angZ -= MPI2;\n"
"\t\t fac = cos(angTmp) / cos(angZ);\n"
"\t\t x *= fac;\n"
"\t\t y *= fac;\n"
@ -2157,8 +2157,8 @@ public:
"\t\t }\n"
"\t\t else\n"
"\t\t {\n"
"\t\t angTmp = M_PI - angZ / Zeps(" << angHoleComp << " * " << angHoleTemp << " - M_PI_2);\n"
"\t\t angZ -= M_PI_2;\n"
"\t\t angTmp = MPI - angZ / Zeps(" << angHoleComp << " * " << angHoleTemp << " - MPI2);\n"
"\t\t angZ -= MPI2;\n"
"\t\t fac = cos(angTmp) / cos(angZ);\n"
"\t\t x *= fac;\n"
"\t\t y *= fac;\n"
@ -2169,7 +2169,7 @@ public:
"\t\t}\n"
"\t\telse\n"
"\t\t{\n"
"\t\t if ((angZ > " << angHoleTemp << ") || (angZ < (M_PI - " << angHoleTemp << ")))\n"
"\t\t if ((angZ > " << angHoleTemp << ") || (angZ < (MPI - " << angHoleTemp << ")))\n"
"\t\t {\n"
"\t\t if ((" << modusBlur << " == 0) || (" << exponentZ << " != 1))\n"
"\t\t {\n"
@ -2180,11 +2180,11 @@ public:
"\t\t else\n"
"\t\t {\n"
"\t\t if (angZ > " << angHoleTemp << ")\n"
"\t\t angTmp = (M_PI - angZ) / " << angHoleComp << " * (M_PI - 2 * " << angHoleComp << ") + " << angHoleComp << " - M_PI_2;\n"
"\t\t angTmp = (MPI - angZ) / " << angHoleComp << " * (MPI - 2 * " << angHoleComp << ") + " << angHoleComp << " - MPI2;\n"
"\t\t else\n"
"\t\t angTmp = M_PI_2 - (angZ / " << angHoleComp << " * (M_PI - 2 * " << angHoleComp << ") + " << angHoleComp << ");\n"
"\t\t angTmp = MPI2 - (angZ / " << angHoleComp << " * (MPI - 2 * " << angHoleComp << ") + " << angHoleComp << ");\n"
"\n"
"\t\t angZ -= M_PI_2;\n"
"\t\t angZ -= MPI2;\n"
"\t\t fac = cos(angTmp) / cos(angZ);\n"
"\t\t x *= fac;\n"
"\t\t y *= fac;\n"
@ -2861,7 +2861,7 @@ public:
<< "\n"
<< "\t\tcase MODE_BLUR_LEGACY:\n"
<< "\t\t radius = (MwcNext01(mwc) + MwcNext01(mwc) + 0.002 * MwcNext01(mwc)) / 2.002;\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - M_PI;\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n"
<< "\t\t Vx = radius * sin(theta);\n"
<< "\t\t Vy = radius * cos(theta);\n"
<< "\t\t radius = pow(Zeps(radius * radius), " << synthPower << " / 2);\n"
@ -2873,7 +2873,7 @@ public:
<< "\n"
<< "\t\tcase MODE_BLUR_NEW:\n"
<< "\t\t radius = 0.5 * (MwcNext01(mwc) + MwcNext01(mwc));\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - M_PI;\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n"
<< "\t\t radius = pow(Zeps(SQR(radius)), -" << synthPower << " / 2);\n"
<< "\t\t thetaFactor = SynthValue(&synth, theta);\n"
<< "\t\t radius = Interpolate(radius, thetaFactor, synthSmooth);\n"
@ -2887,7 +2887,7 @@ public:
<< "\t\t theta = 2 * asin((MwcNext01(mwc) - 0.5) * 2);\n"
<< "\t\t thetaFactor = SynthValue(&synth, theta);\n"
<< "\t\t Vy = Interpolate(Vy, thetaFactor, synthSmooth);\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (theta / M_PI);\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (theta / MPI);\n"
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (Vy - 1);\n"
<< "\t\t break;\n"
<< "\n"
@ -2980,7 +2980,7 @@ public:
<< "\t\t theta = precalcAtanxy / 2;\n"
<< "\n"
<< "\t\t if (MwcNext01(mwc) < 0.5)\n"
<< "\t\t theta += M_PI;\n"
<< "\t\t theta += MPI;\n"
<< "\n"
<< "\t\t SynthSinCos(&synth, theta, &s, &c, synthSmooth);\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * radius * c;\n"
@ -2990,8 +2990,8 @@ public:
<< "\t\tcase MODE_DISC:\n"
<< "\t\t Vx = vIn.x;\n"
<< "\t\t Vy = vIn.y;\n"
<< "\t\t theta = precalcAtanxy / M_PI;\n"
<< "\t\t radius = M_PI * pow(Zeps(precalcSumSquares), " << synthPower << " / 2);\n"
<< "\t\t theta = precalcAtanxy / MPI;\n"
<< "\t\t radius = MPI * pow(Zeps(precalcSumSquares), " << synthPower << " / 2);\n"
<< "\t\t SynthSinCos(&synth, radius, &s, &c, synthSmooth);\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * s * theta;\n"
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * c * theta;\n"
@ -3020,7 +3020,7 @@ public:
<< "\n"
<< "\t\tcase MODE_BLUR_RING:\n"
<< "\t\t radius = 1 + 0.1 * (MwcNext01(mwc) + MwcNext01(mwc) - 1) * " << synthPower << ";\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - M_PI;\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n"
<< "\t\t thetaFactor = SynthValue(&synth, theta);\n"
<< "\t\t radius = Interpolate(radius, thetaFactor, synthSmooth);\n"
<< "\t\t s = sincos(theta, &c);\n"
@ -3029,7 +3029,7 @@ public:
<< "\t\t break;\n"
<< "\n"
<< "\t\tcase MODE_BLUR_RING2:\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - M_PI;\n"
<< "\t\t theta = M_2PI * MwcNext01(mwc) - MPI;\n"
<< "\t\t radius = pow(Zeps(MwcNext01(mwc)), " << synthPower << ");\n"
<< "\t\t radius = SynthValue(&synth, theta) + 0.1 * radius;\n"
<< "\t\t s = sincos(theta, &c);\n"
@ -3354,11 +3354,11 @@ public:
" {\n"
" case SINCOS_MULTIPLY:\n"
" *s = *s * SynthValue(synth, theta);\n"
" *c = *c * SynthValue(synth, theta + M_PI / 2);\n"
" *c = *c * SynthValue(synth, theta + MPI / 2);\n"
" break;\n"
" case SINCOS_MIXIN:\n"
" *s = (1 - synth->SynthMix) * *s + (SynthValue(synth, theta) - 1);\n"
" *c = (1 - synth->SynthMix) * *c + (SynthValue(synth, theta + M_PI / 2) - 1);\n"
" *c = (1 - synth->SynthMix) * *c + (SynthValue(synth, theta + MPI / 2) - 1);\n"
" break;\n"
" }\n"
"\n"
@ -4206,7 +4206,7 @@ public:
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t real_t x, s, c;\n"
<< "\t\t x = ((int)(MwcNext01(mwc) * 2)) ? " << workpower << " + (MwcNext01(mwc) * " << scatter << " + " << offset << " + edge) * M_PI : -(MwcNext01(mwc) * " << scatter << " + " << offset << " + edge) * M_PI;\n"
<< "\t\t x = ((int)(MwcNext01(mwc) * 2)) ? " << workpower << " + (MwcNext01(mwc) * " << scatter << " + " << offset << " + edge) * MPI : -(MwcNext01(mwc) * " << scatter << " + " << offset << " + edge) * MPI;\n"
<< "\t\t s = sincos(x, &c);\n"
<< "\n"
<< "\t\t if (" << staticc << " > 1 || " << staticc << " == -1)\n"
@ -4236,7 +4236,7 @@ public:
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t real_t xang = (ang + M_PI) / " << alpha << ";\n"
<< "\t\t real_t xang = (ang + MPI) / " << alpha << ";\n"
<< "\t\t xang = xang - (int)xang;\n"
<< "\t\t xang = (xang < 0.5) ? xang : 1 - xang;\n"
<< "\t\t coeff = 1 / cos(xang * " << alpha << ");\n"
@ -4641,10 +4641,10 @@ public:
<< "\t\treal_t r = precalcSqrtSumSquares;\n"
<< "\t\treal_t a2 = a + " << angle << ";\n"
<< "\n"
<< "\t\tif (a2 < -M_PI)\n"
<< "\t\tif (a2 < -MPI)\n"
<< "\t\t a2 += M_2PI;\n"
<< "\n"
<< "\t\tif (a2 > M_PI)\n"
<< "\t\tif (a2 > MPI)\n"
<< "\t\t a2 -= M_2PI;\n"
<< "\n"
<< "\t\treal_t s, c;\n"
@ -4654,7 +4654,7 @@ public:
<< "\n"
<< "\t\tif (" << hypergon << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = fmod(fabs(a), (real_t)M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n"
<< "\t\t temp1 = fmod(fabs(a), (real_t)M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n"
<< "\t\t temp2 = Sqr(tan(temp1)) + 1;\n"
<< "\n"
<< "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n"
@ -4669,13 +4669,13 @@ public:
<< "\n"
<< "\t\tif (" << star << "!= 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), (real_t)M_2PI / " << starN << ") - M_PI / " << starN << "));\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), (real_t)M_2PI / " << starN << ") - MPI / " << starN << "));\n"
<< "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << lituus << " != 0)\n"
<< "\t\t{\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / MPI + 1), " << invLituusA << ");\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << super << " != 0)\n"
@ -4689,7 +4689,7 @@ public:
<< "\t\t{\n"
<< "\t\t if (" << hypergon << " != 0.0)\n"
<< "\t\t {\n"
<< "\t\t temp1 = fmod(fabs(a2), (real_t)M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n"
<< "\t\t temp1 = fmod(fabs(a2), (real_t)M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n"
<< "\t\t temp2 = Sqr(tan(temp1)) + 1;\n"
<< "\n"
<< "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n"
@ -4704,13 +4704,13 @@ public:
<< "\n"
<< "\t\t if (" << star << " != 0)\n"
<< "\t\t {\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a2), (real_t)M_2PI / " << starN << ") - M_PI / " << starN << "));\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a2), (real_t)M_2PI / " << starN << ") - MPI / " << starN << "));\n"
<< "\t\t total2 += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n"
<< "\t\t }\n"
<< "\n"
<< "\t\t if (" << lituus << " != 0)\n"
<< "\t\t {\n"
<< "\t\t total2 += " << lituus << " * pow(fabs(a2 / M_PI + 1), " << invLituusA << ");\n"
<< "\t\t total2 += " << lituus << " * pow(fabs(a2 / MPI + 1), " << invLituusA << ");\n"
<< "\t\t }\n"
<< "\n"
<< "\t\t if (" << super << " != 0)\n"
@ -4895,7 +4895,7 @@ public:
<< "\n"
<< "\t\tif (" << hypergon << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n"
<< "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n"
<< "\t\t temp2 = Sqr(tan(temp1)) + 1;\n"
<< "\n"
<< "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n"
@ -4910,13 +4910,13 @@ public:
<< "\n"
<< "\t\tif (" << star << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - MPI / " << starN << "));\n"
<< "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << lituus << " != 0)\n"
<< "\t\t{\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / MPI + 1), " << invLituusA << ");\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << super << " != 0)\n"
@ -5092,7 +5092,7 @@ public:
<< "\n"
<< "\t\tif (" << hypergon << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n"
<< "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n"
<< "\t\t temp2 = Sqr(tan(temp1)) + 1;\n"
<< "\n"
<< "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n"
@ -5107,13 +5107,13 @@ public:
<< "\n"
<< "\t\tif (" << star << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - MPI / " << starN << "));\n"
<< "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << lituus << " != 0)\n"
<< "\t\t{\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / MPI + 1), " << invLituusA << ");\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << super << " != 0)\n"
@ -5290,7 +5290,7 @@ public:
<< "\n"
<< "\t\tif (" << hypergon << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n"
<< "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - MPI / " << hypergonN << ";\n"
<< "\t\t temp2 = Sqr(tan(temp1)) + 1;\n"
<< "\n"
<< "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n"
@ -5305,13 +5305,13 @@ public:
<< "\n"
<< "\t\tif (" << star << " != 0)\n"
<< "\t\t{\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n"
<< "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - MPI / " << starN << "));\n"
<< "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << lituus << " != 0)\n"
<< "\t\t{\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n"
<< "\t\t total += " << lituus << " * pow(fabs(a / MPI + 1), " << invLituusA << ");\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tif (" << super << " != 0)\n"

View File

@ -690,16 +690,16 @@ public:
<< "\n"
<< "\t\tif (" << optDir << " < 0)\n"
<< "\t\t{\n"
<< "\t\t wag = sin(curve1 * M_PI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (sin(curveTwo * M_PI));\n"
<< "\t\t wag3 = sin(curve4 * M_PI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (cos(curve3 * M_PI));\n"
<< "\t\t wag = sin(curve1 * MPI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (sin(curveTwo * MPI));\n"
<< "\t\t wag3 = sin(curve4 * MPI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (cos(curve3 * MPI));\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t wag = sin(curve1 * M_PI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * M_PI));\n"
<< "\t\t wag3 = sin(curve4 * M_PI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (sin(curveTwo * M_PI));\n"
<< "\t\t wag = sin(curve1 * MPI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * MPI));\n"
<< "\t\t wag3 = sin(curve4 * MPI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (sin(curveTwo * MPI));\n"
<< "\t\t}\n"
<< "\n"
<< "\t\twag2 = sin(curveTwo * M_PI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * M_PI));\n"
<< "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * MPI));\n"
<< "\n"
<< "\t\tif (" << smooth12 << " <= 1)\n"
<< "\t\t wag12 = wag;\n"

View File

@ -12,7 +12,7 @@ namespace EmberCLns
/// <summary>
/// OpenCL equivalent of Palette::RgbToHsv().
/// </summary>
static const char* RgbToHsvFunctionString =
static const char* RgbToHsvFunctionString =
//rgb 0 - 1,
//h 0 - 6, s 0 - 1, v 0 - 1
"static inline void RgbToHsv(real4_bucket* rgb, real4_bucket* hsv)\n"
@ -82,9 +82,9 @@ static const char* RgbToHsvFunctionString =
/// <summary>
/// OpenCL equivalent of Palette::HsvToRgb().
/// </summary>
static const char* HsvToRgbFunctionString =
static const char* HsvToRgbFunctionString =
//h 0 - 6, s 0 - 1, v 0 - 1
//rgb 0 - 1
//rgb 0 - 1
"static inline void HsvToRgb(real4_bucket* hsv, real4_bucket* rgb)\n"
"{\n"
" int j;\n"
@ -118,11 +118,11 @@ static const char* HsvToRgbFunctionString =
/// <summary>
/// OpenCL equivalent of Palette::CalcAlpha().
/// </summary>
static const char* CalcAlphaFunctionString =
static const char* CalcAlphaFunctionString =
"static inline real_t CalcAlpha(real_bucket_t density, real_bucket_t gamma, real_bucket_t linrange)\n"//Not the slightest clue what this is doing.//DOC
"{\n"
" real_bucket_t frac, alpha, funcval = pow(linrange, gamma);\n"
"\n"
"\n"
" if (density > 0)\n"
" {\n"
" if (density < linrange)\n"
@ -147,13 +147,13 @@ static const char* CalcAlphaFunctionString =
/// during final accumulation, which only takes floats.
/// </summary>
static const char* CurveAdjustFunctionString =
"static inline void CurveAdjust(__constant real4reals_bucket* csa, float* a, uint index)\n"
"{\n"
" uint tempIndex = (uint)clamp(*a, (float)0.0, (float)COLORMAP_LENGTH_MINUS_1);\n"
" uint tempIndex2 = (uint)clamp((float)csa[tempIndex].m_Real4.x, (float)0.0, (float)COLORMAP_LENGTH_MINUS_1);\n"
"\n"
" *a = (float)round(csa[tempIndex2].m_Reals[index]);\n"
"}\n";
"static inline void CurveAdjust(__constant real4reals_bucket* csa, float* a, uint index)\n"
"{\n"
" uint tempIndex = (uint)clamp(*a * (float)COLORMAP_LENGTH_MINUS_1, (float)0.0, (float)COLORMAP_LENGTH_MINUS_1);\n"
" uint tempIndex2 = (uint)clamp((float)csa[tempIndex].m_Real4.x * (float)COLORMAP_LENGTH_MINUS_1, (float)0.0, (float)COLORMAP_LENGTH_MINUS_1);\n"
"\n"
" *a = (float)csa[tempIndex2].m_Reals[index];\n"
"}\n";
/// <summary>
/// Use MWC 64 from David Thomas at the Imperial College of London for
@ -197,7 +197,7 @@ static const char* RandFunctionString =
/// <summary>
/// OpenCL equivalent Renderer::AddToAccum().
/// </summary>
static const char* AddToAccumWithCheckFunctionString =
static const char* AddToAccumWithCheckFunctionString =
"inline bool AccumCheck(int superRasW, int superRasH, int i, int ii, int j, int jj)\n"
"{\n"
" return (j + jj >= 0 && j + jj < superRasH && i + ii >= 0 && i + ii < superRasW);\n"
@ -207,7 +207,7 @@ static const char* AddToAccumWithCheckFunctionString =
/// <summary>
/// OpenCL equivalent various CarToRas member functions.
/// </summary>
static const char* CarToRasFunctionString =
static const char* CarToRasFunctionString =
"inline void CarToRasConvertPointToSingle(__constant CarToRasCL* carToRas, Point* point, uint* singleBufferIndex)\n"
"{\n"
" *singleBufferIndex = (uint)(carToRas->m_PixPerImageUnitW * point->m_X - carToRas->m_RasLlX) + (carToRas->m_RasWidth * (uint)(carToRas->m_PixPerImageUnitH * point->m_Y - carToRas->m_RasLlY));\n"
@ -225,29 +225,27 @@ static const char* CarToRasFunctionString =
static string AtomicString()
{
ostringstream os;
os <<
"void AtomicAdd(volatile __global real_bucket_t* source, const real_bucket_t operand)\n"
"{\n"
" union\n"
" {\n"
" atomi intVal;\n"
" real_bucket_t realVal;\n"
" } newVal;\n"
"\n"
" union\n"
" {\n"
" atomi intVal;\n"
" real_bucket_t realVal;\n"
" } prevVal;\n"
"\n"
" do\n"
" {\n"
" prevVal.realVal = *source;\n"
" newVal.realVal = prevVal.realVal + operand;\n"
" } while (atomic_cmpxchg((volatile __global atomi*)source, prevVal.intVal, newVal.intVal) != prevVal.intVal);\n"
"}\n";
"void AtomicAdd(volatile __global real_bucket_t* source, const real_bucket_t operand)\n"
"{\n"
" union\n"
" {\n"
" atomi intVal;\n"
" real_bucket_t realVal;\n"
" } newVal;\n"
"\n"
" union\n"
" {\n"
" atomi intVal;\n"
" real_bucket_t realVal;\n"
" } prevVal;\n"
"\n"
" do\n"
" {\n"
" prevVal.realVal = *source;\n"
" newVal.realVal = prevVal.realVal + operand;\n"
" } while (atomic_cmpxchg((volatile __global atomi*)source, prevVal.intVal, newVal.intVal) != prevVal.intVal);\n"
"}\n";
return os.str();
}
}

View File

@ -70,16 +70,21 @@ static string ConstantDefinesString(bool doublePrecision)
"#define THREADS_PER_WARP 32u\n"
"#define NWARPS (NTHREADS / THREADS_PER_WARP)\n"
"#define COLORMAP_LENGTH 256u\n"
"#define COLORMAP_LENGTH_MINUS_1 255u\n"
"#define COLORMAP_LENGTH_MINUS_1 255\n"
"#define DE_THRESH 100u\n"
"#define BadVal(x) (((x) != (x)) || ((x) > 1e10) || ((x) < -1e10))\n"
"#define SQR(x) ((x) * (x))\n"
"#define CUBE(x) ((x) * (x) * (x))\n"
"#define M_2PI (M_PI * 2)\n"
"#define M_3PI (M_PI * 3)\n"
"#define MPI ((real_t)M_PI)\n"
"#define MPI2 ((real_t)M_PI_2)\n"
"#define MPI4 ((real_t)M_PI_4)\n"
"#define M1PI ((real_t)M_1_PI)\n"
"#define M2PI ((real_t)M_2_PI)\n"
"#define M_2PI (MPI * 2)\n"
"#define M_3PI (MPI * 3)\n"
"#define SQRT5 2.2360679774997896964091736687313\n"
"#define M_PHI 1.61803398874989484820458683436563\n"
"#define DEG_2_RAD (M_PI / 180)\n"
"#define DEG_2_RAD (MPI / 180)\n"
"\n"
"//Index in each dimension of a thread within a block.\n"
"#define THREAD_ID_X (get_local_id(0))\n"

View File

@ -83,8 +83,8 @@ const string& FinalAccumOpenCLKernelCreator::FinalAccumEntryPoint(bool earlyClip
if (alphaAccum)
{
alphaBase = transparency ? 0 : 255;//See the table below.
alphaScale = transparency ? 255 : 0;
alphaBase = transparency ? 0 : 1;//See the table below.
alphaScale = transparency ? 1 : 0;
}
if (earlyClip)
@ -260,9 +260,9 @@ string FinalAccumOpenCLKernelCreator::CreateFinalAccumKernelString(bool earlyCli
if (alphaAccum)
{
if (alphaCalc)
os << " finalColor.m_Float4.w = (float)newBucket.m_Real4.w * 255.0f;\n";
os << " finalColor.m_Float4.w = (float)newBucket.m_Real4.w;\n";
else
os << " finalColor.m_Float4.w = 255.0f;\n";
os << " finalColor.m_Float4.w = 1.0f;\n";
}
}
else
@ -296,7 +296,6 @@ string FinalAccumOpenCLKernelCreator::CreateFinalAccumKernelString(bool earlyCli
" CurveAdjust(csa, &(finalColor.m_Floats[2]), 3);\n"
" }\n"
"\n"
" finalColor.m_Float4 /= 255.0f;\n"
" write_imagef(pixels, finalCoord, finalColor.m_Float4);\n"//Use write_imagef instead of write_imageui because only the former works when sharing with an OpenGL texture.
" barrier(CLK_GLOBAL_MEM_FENCE);\n"//Required, or else page tearing will occur during interactive rendering.
"}\n"
@ -335,7 +334,7 @@ string FinalAccumOpenCLKernelCreator::CreateGammaCorrectionFunctionString(bool g
<< " {\n"
<< " tmp = bucket->m_Reals[3];\n"
<< " alpha = CalcAlpha(tmp, g, linRange);\n"
<< " ls = vibrancy * 256.0 * alpha / tmp;\n"
<< " ls = vibrancy * alpha / tmp;\n"
<< " alpha = clamp(alpha, (real_bucket_t)0.0, (real_bucket_t)1.0);\n"
<< " }\n"
<< "\n"
@ -343,7 +342,7 @@ string FinalAccumOpenCLKernelCreator::CreateGammaCorrectionFunctionString(bool g
<< "\n"
<< " for (uint rgbi = 0; rgbi < 3; rgbi++)\n"
<< " {\n"
<< " a = newRgb.m_Reals[rgbi] + ((1.0 - vibrancy) * 256.0 * pow(fabs(bucket->m_Reals[rgbi]), g));\n"
<< " a = newRgb.m_Reals[rgbi] + ((1.0 - vibrancy) * pow(fabs(bucket->m_Reals[rgbi]), g));\n"
<< "\n";
if (!alphaCalc)
@ -362,7 +361,7 @@ string FinalAccumOpenCLKernelCreator::CreateGammaCorrectionFunctionString(bool g
os <<
"\n"
" correctedChannels[rgbi] = (" << dataType << ")clamp(a, (real_bucket_t)0.0, (real_bucket_t)255.0);\n"
" correctedChannels[rgbi] = (" << dataType << ")clamp(a, (real_bucket_t)0.0, (real_bucket_t)1.0);\n"
" }\n"
"\n";
@ -399,9 +398,9 @@ string FinalAccumOpenCLKernelCreator::CreateCalcNewRgbFunctionString(bool global
"static void CalcNewRgb(" << (globalBucket ? "__global " : "") << "real4reals_bucket* oldRgb, real_bucket_t ls, real_bucket_t highPow, real4reals_bucket* newRgb)\n"
"{\n"
" int rgbi;\n"
" real_bucket_t newls, lsratio;\n"
" real_bucket_t lsratio;\n"
" real4reals_bucket newHsv;\n"
" real_bucket_t maxa, maxc;\n"
" real_bucket_t maxa, maxc, newls;\n"
" real_bucket_t adjhlp;\n"
"\n"
" if (ls == 0 || (oldRgb->m_Real4.x == 0 && oldRgb->m_Real4.y == 0 && oldRgb->m_Real4.z == 0))\n"//Can't do a vector compare to zero.
@ -413,35 +412,31 @@ string FinalAccumOpenCLKernelCreator::CreateCalcNewRgbFunctionString(bool global
//Identify the most saturated channel.
" maxc = max(max(oldRgb->m_Reals[0], oldRgb->m_Reals[1]), oldRgb->m_Reals[2]);\n"
" maxa = ls * maxc;\n"
" newls = 1 / maxc;\n"
"\n"
//If a channel is saturated and highlight power is non-negative
//modify the color to prevent hue shift.
" if (maxa > 255 && highPow >= 0)\n"
" if (maxa > 1 && highPow >= 0)\n"
" {\n"
" newls = 255.0 / maxc;\n"
" lsratio = pow(newls / ls, highPow);\n"
"\n"
//Calculate the max-value color (ranged 0 - 1).
" for (rgbi = 0; rgbi < 3; rgbi++)\n"
" newRgb->m_Reals[rgbi] = newls * oldRgb->m_Reals[rgbi] / 255.0;\n"
" newRgb->m_Reals[rgbi] = newls * oldRgb->m_Reals[rgbi];\n"
"\n"
//Reduce saturation by the lsratio.
" RgbToHsv(&(newRgb->m_Real4), &(newHsv.m_Real4));\n"
" newHsv.m_Real4.y *= lsratio;\n"
" HsvToRgb(&(newHsv.m_Real4), &(newRgb->m_Real4));\n"
"\n"
" for (rgbi = 0; rgbi < 3; rgbi++)\n"//Unrolling and vectorizing makes no difference.
" newRgb->m_Reals[rgbi] *= 255.0;\n"
" }\n"
" else\n"
" {\n"
" newls = 255.0 / maxc;\n"
" adjhlp = -highPow;\n"
"\n"
" if (adjhlp > 1)\n"
" adjhlp = 1;\n"
"\n"
" if (maxa <= 255)\n"
" if (maxa <= 1)\n"
" adjhlp = 1;\n"
"\n"
//Calculate the max-value color (ranged 0 - 1) interpolated with the old behavior.

View File

@ -669,7 +669,7 @@ bool RendererCL<T, bucketT>::Alloc(bool histOnly)
if (b && !(b = wrapper.AddBuffer(m_SpatialFilterParamsBufferName, sizeof(m_SpatialFilterCL)))) { AddToReport(loc); }
if (b && !(b = wrapper.AddBuffer(m_CurvesCsaName, SizeOf(m_Csa.m_Entries)))) { AddToReport(loc); }
if (b && !(b = wrapper.AddBuffer(m_CurvesCsaName, SizeOf(m_Csa)))) { AddToReport(loc); }
if (b && !(b = wrapper.AddBuffer(m_AccumBufferName, size))) { AddToReport(loc); }//Accum buffer.
@ -877,6 +877,17 @@ EmberStats RendererCL<T, bucketT>::Iterate(size_t iterCount, size_t temporalSamp
return stats;
}
/// <summary>
/// Override which just passes false to the base.
/// This is because curves are scaled from 0-1 to 0-255 or 0-65535 on the CPU, but need to be kept as 0-1 for OpenCL because the texture expects normalized values.
/// </summary>
/// <param name="scale">Ignored</param>
template <typename T, typename bucketT>
void RendererCL<T, bucketT>::ComputeCurves(bool scale)
{
Renderer<T, bucketT>::ComputeCurves(false);
}
/// <summary>
/// Private functions for making and running OpenCL programs.
/// </summary>
@ -1312,7 +1323,7 @@ eRenderStatus RendererCL<T, bucketT>::RunFinalAccum()
if (b && !(b = wrapper.AddAndWriteBuffer(m_SpatialFilterParamsBufferName, reinterpret_cast<void*>(&m_SpatialFilterCL), sizeof(m_SpatialFilterCL)))) { AddToReport(loc); }
if (b && !(b = wrapper.AddAndWriteBuffer(m_CurvesCsaName, m_Csa.m_Entries.data(), SizeOf(m_Csa.m_Entries)))) { AddToReport(loc); }
if (b && !(b = wrapper.AddAndWriteBuffer(m_CurvesCsaName, m_Csa.data(), SizeOf(m_Csa)))) { AddToReport(loc); }
//Since early clip requires gamma correcting the entire accumulator first,
//it can't be done inside of the normal final accumulation kernel, so

View File

@ -168,6 +168,7 @@ protected:
virtual eRenderStatus GaussianDensityFilter() override;
virtual eRenderStatus AccumulatorToFinalImage(byte* pixels, size_t finalOffset) override;
virtual EmberStats Iterate(size_t iterCount, size_t temporalSample) override;
virtual void ComputeCurves(bool scale) override;
#ifndef TEST_CL
private:

View File

@ -128,51 +128,53 @@ void MakeTestAllVarsRegPrePost(vector<Ember<T>>& embers)
*/
Ember<T> ember1;
unique_ptr<Variation<T>> regVar(varList->GetVariationCopy(index, eVariationType::VARTYPE_REG));
//unique_ptr<Variation<T>> preVar(varList->GetVariationCopy("pre_" + regVar->Name()));
//unique_ptr<Variation<T>> postVar(varList->GetVariationCopy("post_" + regVar->Name()));
unique_ptr<Variation<T>> preVar(varList->GetVariationCopy("pre_" + regVar->Name()));
unique_ptr<Variation<T>> postVar(varList->GetVariationCopy("post_" + regVar->Name()));
ember1.m_FinalRasW = 1024;
ember1.m_FinalRasH = 1024;
ember1.m_Quality = 500;
Xform<T> xform1(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
Xform<T> xform2(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
Xform<T> xform3(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
//Xform<T> xform4(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
//Xform<T> xform5(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
//Xform<T> xform6(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
//Xform<T> xform7(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
//if (preVar.get() && postVar.get())
//{
//xform1.AddVariation(preVar->Copy());
//xform2.AddVariation(regVar->Copy());
//xform3.AddVariation(postVar->Copy());
//xform4.AddVariation(preVar->Copy());
//xform4.AddVariation(regVar->Copy());
//xform5.AddVariation(preVar->Copy());
//xform5.AddVariation(postVar->Copy());
//xform6.AddVariation(regVar->Copy());
//xform6.AddVariation(postVar->Copy());
//xform7.AddVariation(preVar->Copy());
//xform7.AddVariation(regVar->Copy());
//xform7.AddVariation(postVar->Copy());
//ember1.AddXform(xform1);
//ember1.AddXform(xform2);
//ember1.AddXform(xform3);
//ember1.AddXform(xform4);
//ember1.AddXform(xform5);
//ember1.AddXform(xform6);
//ember1.AddXform(xform7);
//}
//else
Xform<T> xform4(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
Xform<T> xform5(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
Xform<T> xform6(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
Xform<T> xform7(0.25f, rand.Frand01<T>(), rand.Frand11<T>(), 1, rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
if (preVar.get() && postVar.get())
{
xform1.AddVariation(preVar->Copy());
xform2.AddVariation(regVar->Copy());
xform3.AddVariation(postVar->Copy());
xform4.AddVariation(preVar->Copy());
xform4.AddVariation(regVar->Copy());
xform5.AddVariation(preVar->Copy());
xform5.AddVariation(postVar->Copy());
xform6.AddVariation(regVar->Copy());
xform6.AddVariation(postVar->Copy());
xform7.AddVariation(preVar->Copy());
xform7.AddVariation(regVar->Copy());
xform7.AddVariation(postVar->Copy());
ember1.AddXform(xform1);
ember1.AddXform(xform2);
ember1.AddXform(xform3);
ember1.AddXform(xform4);
ember1.AddXform(xform5);
ember1.AddXform(xform6);
ember1.AddXform(xform7);
}
else
{
xform1.AddVariation(regVar->Copy());
xform2.AddVariation(regVar->Copy());
xform3.AddVariation(regVar->Copy());
//xform4.AddVariation(regVar->Copy());
xform4.AddVariation(regVar->Copy());
ember1.AddXform(xform1);
ember1.AddXform(xform2);
ember1.AddXform(xform3);
//ember1.AddXform(xform4);
ember1.AddXform(xform4);
}
ss << index << "_" << regVar->Name();
ember1.m_Name = ss.str();
ss.str("");
@ -1041,9 +1043,23 @@ void TestFuncs()
{
auto vlf(VariationList<float>::Instance());
vector<string> stringVec;
stringVec.push_back("M_E");
stringVec.push_back("M_LOG2E");
stringVec.push_back("M_LOG10E");
stringVec.push_back("M_LN2");
stringVec.push_back("M_LN10");
stringVec.push_back("M_PI");
stringVec.push_back("M_PI_2");
stringVec.push_back("M_PI_4");
stringVec.push_back("M_1_PI");
stringVec.push_back("M_2_PI");
stringVec.push_back("M_2_SQRTPI");
stringVec.push_back("M_SQRT2");
stringVec.push_back("M_SQRT1_2");
//stringVec.push_back("M_2PI");
//stringVec.push_back("M_3PI");
//stringVec.push_back("DEG_2_RAD");
//stringVec.push_back("log(");
for (size_t i = 0; i < vlf->Size(); i++)
{
auto var = vlf->GetVariation(i);
@ -1965,8 +1981,8 @@ int _tmain(int argc, _TCHAR* argv[])
vector<Ember<double>> dv;
list<Ember<float>> fl;
list<Ember<double>> dl;
TestFuncs();
/* string line = "title=\"cj_aerie\" smooth=no", delim = " =\"";
/* TestFuncs();
string line = "title=\"cj_aerie\" smooth=no", delim = " =\"";
auto vec = Split(line, delim, true);
for (auto& s : vec) cout << s << endl;
@ -1992,8 +2008,8 @@ int _tmain(int argc, _TCHAR* argv[])
return 1;
*/
//MakeTestAllVarsRegPrePostComboFile("testallvarsout.flame");
return 0;
/*
/* return 0;
TestThreadedKernel();