mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-12 03:04:51 -04:00
--Bug fixes
-Ensure all OpenCL functions that take multiple arguments cast literal values to real_t.
This commit is contained in:
@ -497,8 +497,8 @@ public:
|
||||
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\tvOut.x = " << weight << " * fma((1 / Zeps(" << x << " * M_2PI)), sin(" << x << " * M_2PI * vIn.x), vIn.x);\n"
|
||||
<< "\t\tvOut.y = " << weight << " * fma((1 / Zeps(" << y << " * M_2PI)), sin(" << y << " * M_2PI * vIn.y), vIn.y);\n"
|
||||
<< "\t\tvOut.x = " << weight << " * fma(((real_t)(1.0) / Zeps(" << x << " * M_2PI)), sin(" << x << " * M_2PI * vIn.x), vIn.x);\n"
|
||||
<< "\t\tvOut.y = " << weight << " * fma(((real_t)(1.0) / Zeps(" << y << " * M_2PI)), sin(" << y << " * M_2PI * vIn.y), vIn.y);\n"
|
||||
<< "\t\tvOut.z = " << DefaultZCl()
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
@ -699,33 +699,33 @@ public:
|
||||
<< "\t\t posNeg = -1;\n"
|
||||
<< "\n"
|
||||
<< "\t\tpang = th / Zeps(" << cycle << ");\n"
|
||||
<< "\t\twig = fma(pang, " << freq << " * 0.5, " << offset << " * " << cycle << ");\n"
|
||||
<< "\t\twig = fma(pang, " << freq << " * (real_t)(0.5), " << offset << " * " << cycle << ");\n"
|
||||
<< "\t\treal_t rad04 = (real_t)(0.4) * rad;\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (" << optDir << " < 0)\n"
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * sin(curveTwo * MPI)); \n"
|
||||
<< "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n"
|
||||
<< "\t\t wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * (real_t)(0.5) * sin(curveTwo * MPI)); \n"
|
||||
<< "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * (real_t)(0.5) * cos(curve3 * MPI)); \n"
|
||||
<< "\t\t}\n"
|
||||
<< "\t\telse\n"
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n"
|
||||
<< "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * 0.5 * sin(curveTwo * MPI)); \n"
|
||||
<< "\t\t wag = sin(curve1* MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * (real_t)(0.5) * cos(curve3 * MPI)); \n"
|
||||
<< "\t\t wag3 = sin(curve4* MPI * " << absOptSc << ") + fma(" << wagsc << ", SQR(rad) * (real_t)(0.4), " << crvsc << " * (real_t)(0.5) * sin(curveTwo * MPI)); \n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * 0.5 * cos(curve3 * MPI)); \n"
|
||||
<< "\t\twag2 = sin(curveTwo * MPI * " << absOptSc << ") + fma(" << wagsc << ", rad04, " << crvsc << " * (real_t)(0.5) * cos(curve3 * MPI)); \n"
|
||||
<< "\n"
|
||||
<< "\t\tif (" << smooth12 << " <= 1)\n"
|
||||
<< "\t\t wag12 = wag; \n"
|
||||
<< "\t\telse if (" << smooth12 << " <= 2 && " << smooth12 << " > 1)\n"
|
||||
<< "\t\t wag12 = fma(wag2, (1 - " << antiOpt1 << "), wag * " << antiOpt1 << "); \n"
|
||||
<< "\t\t wag12 = fma(wag2, ((real_t)(1.0) - " << antiOpt1 << "), wag * " << antiOpt1 << "); \n"
|
||||
<< "\t\telse if (" << smooth12 << " > 2)\n"
|
||||
<< "\t\t wag12 = wag2; \n"
|
||||
<< "\n"
|
||||
<< "\t\tif (" << smooth3 << " == 0)\n"
|
||||
<< "\t\t waggle = wag12; \n"
|
||||
<< "\t\telse if (" << smooth3 << " > 0)\n"
|
||||
<< "\t\t waggle = fma(wag12, (1 - " << smooth3 << "), wag3 * " << smooth3 << "); \n"
|
||||
<< "\t\t waggle = fma(wag12, ((real_t)(1.0) - " << smooth3 << "), wag3 * " << smooth3 << "); \n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t cospetthcl = " << weight << " * (real_t)(0.5) * " << "cos(fma(" << numPetals << ", th, " << c << ")) * " << l << "; \n"
|
||||
<< "\n"
|
||||
@ -735,13 +735,13 @@ public:
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = " << refSc << "* cospetthcl * cth; \n"
|
||||
<< "\t\t vOut.y = " << refSc << "* cospetthcl * sth; \n"
|
||||
<< "\t\t vOut.z = " << weight << " * -0.5 * (fma(" << z2 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t vOut.z = " << weight << " * (real_t)(-0.5) * (fma(" << z2 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = cospetthcl * cth; \n"
|
||||
<< "\t\t vOut.y = cospetthcl * sth; \n"
|
||||
<< "\t\t vOut.z = " << weight << " * 0.5 * (fma(" << z1 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t vOut.z = " << weight << " * (real_t)(0.5) * (fma(" << z1 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\t\telse\n"
|
||||
@ -750,13 +750,13 @@ public:
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = cospetthcl * cth; \n"
|
||||
<< "\t\t vOut.y = cospetthcl * sth; \n"
|
||||
<< "\t\t vOut.z = " << weight << " * 0.5 * (fma(" << z1 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t vOut.z = " << weight << " * (real_t)(0.5) * (fma(" << z1 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = cospetthcl * cth; \n"
|
||||
<< "\t\t vOut.y = cospetthcl * sth; \n"
|
||||
<< "\t\t vOut.z = " << weight << " * 0.5 * (fma(" << z1 << ", waggle, Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t vOut.z = " << weight << " * (real_t)(0.5) * (fma(" << z1 << ", waggle, Sqr(rad * (real_t)(0.5)) * sin(wig) * " << wigScale << ") + " << dist << "); \n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\t}\n";
|
||||
@ -3319,7 +3319,7 @@ public:
|
||||
<< "\t\tif (rad > " << radius << ")\n"
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t real_t ang = MwcNext01(mwc) * M_2PI;\n"
|
||||
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), 2, -1.0)) / MPI : acos(exp(log(1 - MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
|
||||
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), (real_t)(2.0), (real_t)(-1.0))) / MPI : acos(exp(log((real_t)(1.0) - MwcNext01(mwc)) * " << power << ") * (real_t)(2.0) - (real_t)(1.0)) / MPI);\n"
|
||||
<< "\t\t real_t aux = r * " << blurover10 << " * (rad - " << radius << ");\n"
|
||||
<< "\t\t bx = aux * cos(ang);\n"
|
||||
<< "\t\t by = aux * sin(ang);\n"
|
||||
@ -3416,7 +3416,7 @@ public:
|
||||
<< "\t\tif (rad > " << radius << ")\n"
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t real_t ang = MwcNext01(mwc) * M_2PI;\n"
|
||||
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), 2, -1.0)) / MPI : acos(exp(log(1 - MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
|
||||
<< "\t\t real_t r = (" << power << " == 1 ? acos(fma(MwcNext01(mwc), 2, (real_t)(-1.0))) / MPI : acos(exp(log(1 - MwcNext01(mwc)) * " << power << ") * 2 - 1) / MPI);\n"
|
||||
<< "\t\t real_t aux = r * " << blurover10 << " * exp(log(rad - " << radius << ") * " << exp << ");\n"
|
||||
<< "\t\t bx = aux * cos(ang);\n"
|
||||
<< "\t\t by = aux * sin(ang);\n"
|
||||
@ -3574,8 +3574,8 @@ public:
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t X = fmod(floor(vIn.x), " << zdens << ") / " << zdens << ";\n"
|
||||
<< "\t\treal_t Y = fmod(floor(vIn.y), " << zdens << ") / " << zdens << ";\n"
|
||||
<< "\t\treal_t random_x = HashShadertoy(X, Y, 0.0);\n"
|
||||
<< "\t\treal_t random_y = HashShadertoy(Y, X, 0.0);\n"
|
||||
<< "\t\treal_t random_x = HashShadertoy(X, Y, (real_t)(0.0));\n"
|
||||
<< "\t\treal_t random_y = HashShadertoy(Y, X, (real_t)(0.0));\n"
|
||||
<< "\t\treal_t a = fma(random_x, " << dist << ", X) * M_2PI;\n"
|
||||
<< "\t\treal_t r = exp(log(fma(random_y, " << dist << ", Y)) * " << power << ");\n"
|
||||
<< "\t\tvOut.x = " << weight << " * cos(a) * r;\n"
|
||||
@ -5808,26 +5808,26 @@ public:
|
||||
<< "\t\t real_t xrand = floor(fabs(vIn.x) + 0.5);\n"
|
||||
<< "\t\t real_t yrand = floor(fabs(vIn.y) + 0.5);\n"
|
||||
<< "\t\t real_t randint0 = HashShadertoy(xrand, yrand, " << seed << ");\n"
|
||||
<< "\t\t real_t randint = fmod(fma(randint0, 32747.0, 12345.0), 65535.0);\n"
|
||||
<< "\t\t real_t randint = fmod(fma(randint0, (real_t)(32747.0), (real_t)(12345.0)), (real_t)(65535.0));\n"
|
||||
<< "\t\t tiletype = fmod(randint, 2.0);\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t xval1 = tiletype < 1 ? x : x - 1;\n"
|
||||
<< "\t\treal_t xval2 = tiletype < 1 ? x - 1 : x;\n"
|
||||
<< "\t\treal2 R = (real2)(pow(pow(fabs(xval1), " << n << ") + pow(fabs(y), " << n << "), " << onen << "), pow(pow(fabs(xval2), " << n << ") + pow(fabs(y - 1), " << n << "), " << onen << "));\n"
|
||||
<< "\t\treal_t r00 = fabs(R.x - 0.5) / " << rmax << ";\n"
|
||||
<< "\t\treal_t r11 = fabs(R.y - 0.5) / " << rmax << ";\n"
|
||||
<< "\t\treal_t r00 = fabs(R.x - (real_t)(0.5)) / " << rmax << ";\n"
|
||||
<< "\t\treal_t r11 = fabs(R.y - (real_t)(0.5)) / " << rmax << ";\n"
|
||||
<< "\t\treal2 xy;\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (r00 < 1)\n"
|
||||
<< "\t\t xy = (real2)(fma(floor(vIn.x), 2.0, x), fma(floor(vIn.y), 2.0, y));\n"
|
||||
<< "\t\t xy = (real2)(fma(floor(vIn.x), (real_t)(2.0), x), fma(floor(vIn.y), (real_t)(2.0), y));\n"
|
||||
<< "\t\telse\n"
|
||||
<< "\t\t xy = (real2)(0.0, 0.0);\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t cost = cos(" << rads << ");\n"
|
||||
<< "\t\treal_t sint = sin(" << rads << ");\n"
|
||||
<< "\t\treal_t roundx = (floor(vIn.x / " << amp << ") + 0.5) * " << amp << ";\n"
|
||||
<< "\t\treal_t roundy = (floor(vIn.y / " << amp << ") + 0.5) * " << amp << ";\n"
|
||||
<< "\t\treal_t roundx = (floor(vIn.x / " << amp << ") + (real_t)(0.5)) * " << amp << ";\n"
|
||||
<< "\t\treal_t roundy = (floor(vIn.y / " << amp << ") + (real_t)(0.5)) * " << amp << ";\n"
|
||||
<< "\t\treal_t vx = vIn.x - roundx;\n"
|
||||
<< "\t\treal_t vy = vIn.y - roundy;\n"
|
||||
<< "\t\treal_t newx = fma(cost, vx, sint * vy);\n"
|
||||
@ -5837,8 +5837,8 @@ public:
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t if (r11 < 1)\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xy.x + fma(floor(vIn.x), 2.0, x) - vIn.x;\n"
|
||||
<< "\t\t vOut.y = xy.y + fma(floor(vIn.y), 2.0, y) - vIn.y;\n"
|
||||
<< "\t\t vOut.x = xy.x + fma(floor(vIn.x), (real_t)(2.0), x) - vIn.x;\n"
|
||||
<< "\t\t vOut.y = xy.y + fma(floor(vIn.y), (real_t)(2.0), y) - vIn.y;\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
@ -6015,7 +6015,7 @@ public:
|
||||
<< "\t\treal_t yrand = floor(vIn.y + 0.5) * " << seed2 << ";\n"
|
||||
<< "\t\treal_t niter = xrand + yrand + xrand * yrand;\n"
|
||||
<< "\t\treal_t randint0 = (niter + " << seed << ") * " << seed2half << ";\n"
|
||||
<< "\t\treal_t randint = fmod(fma(randint0, 32747.0, 12345.0), 65535.0);\n"
|
||||
<< "\t\treal_t randint = fmod(fma(randint0, (real_t)(32747.0), (real_t)(12345.0)), (real_t)(65535.0));\n"
|
||||
<< "\t\t tiletype = fmod(randint, 2.0);\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
@ -6744,7 +6744,7 @@ public:
|
||||
<< "\t\treal_t ax = floor(vIn.y * " << freqx << " / M_2PI);\n"
|
||||
<< "\t\tax = sin(ax * (real_t)(12.9898) + ax * (real_t)(78.233) + (real_t)(1.0) + vIn.y * " << yfact001 << ") * (real_t)(43758.5453);\n"
|
||||
<< "\t\tax = ax - (int) ax;\n"
|
||||
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : 0.0;\n"
|
||||
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : (real_t)(0.0);\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = " << weight << " * fma(sin(vIn.y * " << freqx << "), ax * ax * " << scalex << ", vIn.x);\n"
|
||||
<< "\t\tvOut.y = " << weight << " * fma(sin(vIn.x * " << freqy << "), " << scaley << ", vIn.y);\n"
|
||||
@ -7035,7 +7035,7 @@ public:
|
||||
<< "\t\treal_t ax = floor(vIn.y * " << freqx2 << ");\n"
|
||||
<< "\t\tax = sin(ax * (real_t)(12.9898) + ax * (real_t)(78.233) + (real_t)(1.0) + vIn.y * " << yfact001 << ") * (real_t)(43758.5453);\n"
|
||||
<< "\t\tax = ax - (int) ax;\n"
|
||||
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : 0.0;\n"
|
||||
<< "\t\tif (" << cont << " == 1) ax = (ax > (real_t)(0.5)) ? (real_t)(1.0) : (real_t)(0.0);\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = " << weight << " * fma(sin(vIn.y * " << freqx << "), ax * ax * " << scalex << ", vIn.x);\n"
|
||||
<< "\t\tvOut.y = " << weight << " * fma(sin(vIn.x * " << freqy << "), " << scaley << ", vIn.y);\n"
|
||||
|
Reference in New Issue
Block a user