Skip to content

Instantly share code, notes, and snippets.

@ze-
Created September 25, 2013 23:04
Show Gist options
  • Save ze-/6707422 to your computer and use it in GitHub Desktop.
Save ze-/6707422 to your computer and use it in GitHub Desktop.
Patch for animatable 5 dimensional turbulence for povray-3.7rc7. See comment below for example and more commentary. New 2D vector turbulence parameter "hyper", cyclicable along the lines of: hyper <sin(2*pi*clock),-1*cos(2*pi*clock)>
diff -ur povray-3.7.0.RC7/source/backend/frame.h povray-3.7.0.RC7.5dturb/source/backend/frame.h
--- povray-3.7.0.RC7/source/backend/frame.h 2013-02-05 17:27:08.000000000 -0800
+++ povray-3.7.0.RC7.5dturb/source/backend/frame.h 2013-09-24 09:09:59.607596915 -0700
@@ -1269,6 +1269,7 @@
VECTOR Turbulence;
int Octaves;
SNGL Lambda, Omega;
+ UV_VECT Hyper;
};
#define Destroy_Finish(x) if ((x)!=NULL) POV_FREE(x)
diff -ur povray-3.7.0.RC7/source/backend/parser/parstxtr.cpp povray-3.7.0.RC7.5dturb/source/backend/parser/parstxtr.cpp
--- povray-3.7.0.RC7/source/backend/parser/parstxtr.cpp 2013-01-31 01:14:21.000000000 -0800
+++ povray-3.7.0.RC7.5dturb/source/backend/parser/parstxtr.cpp 2013-09-24 09:20:30.748557094 -0700
@@ -4543,6 +4543,10 @@
Turb->Lambda = Parse_Float();
END_CASE
+ CASE (HYPER_TOKEN)
+ Parse_UV_Vect(Turb->Hyper);
+ END_CASE
+
OTHERWISE
UNGET
EXIT
diff -ur povray-3.7.0.RC7/source/backend/parser/reswords.cpp povray-3.7.0.RC7.5dturb/source/backend/parser/reswords.cpp
--- povray-3.7.0.RC7/source/backend/parser/reswords.cpp 2012-02-05 12:53:49.000000000 -0800
+++ povray-3.7.0.RC7.5dturb/source/backend/parser/reswords.cpp 2013-09-24 09:28:13.015541247 -0700
@@ -331,6 +331,7 @@
{HIERARCHY_TOKEN, "hierarchy"},
{HOLLOW_TOKEN, "hollow"},
{HYPERCOMPLEX_TOKEN, "hypercomplex"},
+ {HYPER_TOKEN, "hyper"},
{IDENTIFIER_TOKEN, "undeclared identifier"},
{INTERIOR_TEXTURE_TOKEN, "interior_texture"},
{INTERNAL_TOKEN, "internal"},
diff -ur povray-3.7.0.RC7/source/backend/parser/reswords.h povray-3.7.0.RC7.5dturb/source/backend/parser/reswords.h
--- povray-3.7.0.RC7/source/backend/parser/reswords.h 2013-01-31 01:14:21.000000000 -0800
+++ povray-3.7.0.RC7.5dturb/source/backend/parser/reswords.h 2013-09-24 09:26:49.296708877 -0700
@@ -302,6 +302,7 @@
HAT_TOKEN,
HEIGHT_FIELD_TOKEN,
HEXAGON_TOKEN,
+ HYPER_TOKEN,
IDENTIFIER_TOKEN,
IFF_TOKEN,
IMAGE_MAP_TOKEN,
diff -ur povray-3.7.0.RC7/source/backend/pattern/pattern.cpp povray-3.7.0.RC7.5dturb/source/backend/pattern/pattern.cpp
--- povray-3.7.0.RC7/source/backend/pattern/pattern.cpp 2012-03-15 16:19:31.000000000 -0700
+++ povray-3.7.0.RC7.5dturb/source/backend/pattern/pattern.cpp 2013-09-25 11:58:42.168659152 -0700
@@ -560,6 +560,7 @@
New->Octaves = 6;
New->Omega = 0.5;
New->Lambda = 2.0;
+ Make_UV_Vector(New->Hyper, 0.0, 0.0);
return(New);
}
diff -ur povray-3.7.0.RC7/source/backend/pattern/warps.cpp povray-3.7.0.RC7.5dturb/source/backend/pattern/warps.cpp
--- povray-3.7.0.RC7/source/backend/pattern/warps.cpp 2013-01-31 01:14:22.000000000 -0800
+++ povray-3.7.0.RC7.5dturb/source/backend/pattern/warps.cpp 2013-09-25 12:13:07.060625010 -0700
@@ -187,7 +187,7 @@
case EXTRA_TURB_WARP:
Turb=reinterpret_cast<TURB *>(Warp);
- DTurbulence (PTurbulence, TPoint, Turb);
+ D5Turbulence (PTurbulence, TPoint, Turb);
TPoint[X] += PTurbulence[X] * Turb->Turbulence[X];
TPoint[Y] += PTurbulence[Y] * Turb->Turbulence[Y];
TPoint[Z] += PTurbulence[Z] * Turb->Turbulence[Z];
@@ -865,6 +865,7 @@
TNew->Octaves = 6;
TNew->Omega = 0.5;
TNew->Lambda = 2.0;
+ Make_UV_Vector(TNew->Hyper, 0.0, 0.0);
New = reinterpret_cast<WARP *>(TNew);
diff -ur povray-3.7.0.RC7/source/backend/texture/texture.cpp povray-3.7.0.RC7.5dturb/source/backend/texture/texture.cpp
--- povray-3.7.0.RC7/source/backend/texture/texture.cpp 2013-01-21 15:03:22.000000000 -0800
+++ povray-3.7.0.RC7.5dturb/source/backend/texture/texture.cpp 2013-09-25 12:28:02.527441488 -0700
@@ -142,6 +142,8 @@
const int MINX = -10000;
const int MINY = MINX;
const int MINZ = MINX;
+const int MINP = MINX;
+const int MINQ = MINX;
const int SINTABSIZE = 1000;
@@ -161,6 +163,8 @@
#define INCRSUMP(mp,s,x,y,z) \
((s)*((mp[1]) + (mp[2])*(x) + (mp[4])*(y) + (mp[6])*(z)))
+#define INCRSUMP5(mp,s,x,y,z,p,q) \
+ ((s)*((mp[1]) + (mp[2])*(x) + (mp[4])*(y) + (mp[6])*(z) + (mp[8])*(p) + (mp[10])*(q)))
/*****************************************************************************
* Local typedefs
@@ -252,6 +256,7 @@
#if !defined(USE_AVX_FMA4_FOR_NOISE)
#define OriNoise Noise
#define OriDNoise DNoise
+ #define OriD5Noise D5Noise
#endif
#define FASTER_NOISE_INIT()
@@ -718,6 +723,389 @@
result[Z] += INCRSUMP(mp, s, x_ix, y_iy, z_jz);
}
+void OriD5Noise(VECTOR result, const VECTOR EPoint, const UV_VECT HPoint)
+{
+ DBL x, y, z, p, q;
+ DBL *mp;
+ int tmp;
+ int ix, iy, iz, ip, iq;
+ int ixiy_hash, ixjy_hash, jxiy_hash, jxjy_hash;
+ int ixiyiz_hash, jxiyiz_hash, ixjyiz_hash, jxjyiz_hash, ixiyjz_hash, jxiyjz_hash, ixjyjz_hash, jxjyjz_hash;
+ int ixiyizip_hash, ixiyizjp_hash, ixiyjzip_hash, ixiyjzjp_hash, ixjyizip_hash, ixjyizjp_hash, ixjyjzip_hash;
+ int ixjyjzjp_hash, jxiyizip_hash, jxiyizjp_hash, jxiyjzip_hash, jxiyjzjp_hash, jxjyizip_hash, jxjyizjp_hash;
+ int jxjyjzip_hash, jxjyjzjp_hash;
+ DBL x_ix, x_jx, y_iy, y_jy, z_iz, z_jz, p_ip, p_jp, q_iq, q_jq;
+ DBL s;
+ DBL sx, sy, sz, sp, sq, tx, ty, tz, tp, tq;
+ DBL txty, sxty, txsy, sxsy, txtytz, txtysz, txsytz, txsysz, sxtytz, sxtysz, sxsytz, sxsysz;
+ DBL txtytztp, txtytzsp, txtysztp, txtyszsp, txsytztp, txsytzsp, txsysztp, txsyszsp;
+ DBL sxtytztp, sxtytzsp, sxtysztp, sxtyszsp, sxsytztp, sxsytzsp, sxsysztp, sxsyszsp;
+
+ // TODO FIXME - global statistics reference
+ // Stats[Calls_To_DNoise]++;
+
+ x = EPoint[X];
+ y = EPoint[Y];
+ z = EPoint[Z];
+ p = HPoint[U];
+ q = HPoint[V];
+
+ /* its equivalent integer lattice point. */
+ /*ix = (int)x; iy = (int)y; iz = (int)z;
+ x_ix = x - ix; y_iy = y - iy; z_iz = z - iz;*/
+ /* JB fix for the range problem */
+ tmp = (x>=0)?(int)x:(int)(x-(1-EPSILON));
+ ix = (int)((tmp-MINX)&0xFFF);
+ x_ix = x-tmp;
+
+ tmp = (y>=0)?(int)y:(int)(y-(1-EPSILON));
+ iy = (int)((tmp-MINY)&0xFFF);
+ y_iy = y-tmp;
+
+ tmp = (z>=0)?(int)z:(int)(z-(1-EPSILON));
+ iz = (int)((tmp-MINZ)&0xFFF);
+ z_iz = z-tmp;
+
+ tmp = (p>=0)?(int)p:(int)(p-(1-EPSILON));
+ ip = (int)((tmp-MINP)&0xFFF);
+ p_ip = p-tmp;
+
+ tmp = (q>=0)?(int)q:(int)(q-(1-EPSILON));
+ iq = (int)((tmp-MINQ)&0xFFF);
+ q_iq = q-tmp;
+
+ x_jx = x_ix-1; y_jy = y_iy-1; z_jz = z_iz-1;
+ p_jp = p_ip-1; q_jq = q_iq-1;
+
+ sx = SCURVE(x_ix); sy = SCURVE(y_iy); sz = SCURVE(z_iz);
+ sp = SCURVE(p_ip); sq = SCURVE(q_iq);
+
+ /* the complement values of sx,sy,sz */
+ tx = 1 - sx; ty = 1 - sy; tz = 1 - sz;
+ tp = 1 - sp; tq = 1 - sq;
+
+ /*
+ * interpolate!
+ */
+ txty = tx * ty;
+ sxty = sx * ty;
+ txsy = tx * sy;
+ sxsy = sx * sy;
+ txtytz = txty * tz;
+ txtysz = txty * sz;
+ txsytz = txsy * tz;
+ txsysz = txsy * sz;
+ sxtytz = sxty * tz;
+ sxtysz = sxty * sz;
+ sxsytz = sxsy * tz;
+ sxsysz = sxsy * sz;
+ txtytztp = txtytz * tp;
+ txtytzsp = txtytz * sp;
+ txtysztp = txtysz * tp;
+ txtyszsp = txtysz * sp;
+ txsytztp = txsytz * tp;
+ txsytzsp = txsytz * sp;
+ txsysztp = txsysz * tp;
+ txsyszsp = txsysz * sp;
+ sxtytztp = sxtytz * tp;
+ sxtytzsp = sxtytz * sp;
+ sxtysztp = sxtysz * tp;
+ sxtyszsp = sxtysz * sp;
+ sxsytztp = sxsytz * tp;
+ sxsytzsp = sxsytz * sp;
+ sxsysztp = sxsysz * tp;
+ sxsyszsp = sxsysz * sp;
+
+ ixiy_hash = Hash2d(ix, iy);
+ jxiy_hash = Hash2d(ix + 1, iy);
+ ixjy_hash = Hash2d(ix, iy + 1);
+ jxjy_hash = Hash2d(ix + 1, iy + 1);
+
+ ixiyiz_hash = Hash2d(ixiy_hash, iz);
+ jxiyiz_hash = Hash2d(jxiy_hash, iz);
+ ixjyiz_hash = Hash2d(ixjy_hash, iz);
+ jxjyiz_hash = Hash2d(jxjy_hash, iz);
+ ixiyjz_hash = Hash2d(ixiy_hash, iz + 1);
+ jxiyjz_hash = Hash2d(jxiy_hash, iz + 1);
+ ixjyjz_hash = Hash2d(ixjy_hash, iz + 1);
+ jxjyjz_hash = Hash2d(jxjy_hash, iz + 1);
+
+ ixiyizip_hash = Hash2d(ixiyiz_hash, ip);
+ ixiyizjp_hash = Hash2d(ixiyiz_hash, ip + 1);
+ ixiyjzip_hash = Hash2d(ixiyjz_hash, ip);
+ ixiyjzjp_hash = Hash2d(ixiyjz_hash, ip + 1);
+ ixjyizip_hash = Hash2d(ixjyiz_hash, ip);
+ ixjyizjp_hash = Hash2d(ixjyiz_hash, ip + 1);
+ ixjyjzip_hash = Hash2d(ixjyjz_hash, ip);
+ ixjyjzjp_hash = Hash2d(ixjyjz_hash, ip + 1);
+ jxiyizip_hash = Hash2d(jxiyiz_hash, ip);
+ jxiyizjp_hash = Hash2d(jxiyiz_hash, ip + 1);
+ jxiyjzip_hash = Hash2d(jxiyjz_hash, ip);
+ jxiyjzjp_hash = Hash2d(jxiyjz_hash, ip + 1);
+ jxjyizip_hash = Hash2d(jxjyiz_hash, ip);
+ jxjyizjp_hash = Hash2d(jxjyiz_hash, ip + 1);
+ jxjyjzip_hash = Hash2d(jxjyjz_hash, ip);
+ jxjyjzjp_hash = Hash2d(jxjyjz_hash, ip + 1);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyizip_hash, iq)];
+ s = txtytztp*tq;
+ result[X] = INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Y] = INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Z] = INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyizip_hash, iq + 1)];
+ s = txtytztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyizjp_hash, iq)];
+ s = txtytzsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyizjp_hash, iq + 1)];
+ s = txtytzsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_iz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyjzip_hash, iq)];
+ s = txtysztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyjzip_hash, iq + 1)];
+ s = txtysztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyjzjp_hash, iq)];
+ s = txtyszsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixiyjzjp_hash, iq + 1)];
+ s = txtyszsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_iy, z_jz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyizip_hash, iq)];
+ s = txsytztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyizip_hash, iq + 1)];
+ s = txsytztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyizjp_hash, iq)];
+ s = txsytzsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyizjp_hash, iq + 1)];
+ s = txsytzsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_iz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyjzip_hash, iq)];
+ s = txsysztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyjzip_hash, iq + 1)];
+ s = txsysztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyjzjp_hash, iq)];
+ s = txsyszsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(ixjyjzjp_hash, iq + 1)];
+ s = txsyszsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_ix, y_jy, z_jz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyizip_hash, iq)];
+ s = sxtytztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyizip_hash, iq + 1)];
+ s = sxtytztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyizjp_hash, iq)];
+ s = sxtytzsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyizjp_hash, iq + 1)];
+ s = sxtytzsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_iz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyjzip_hash, iq)];
+ s = sxtysztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyjzip_hash, iq + 1)];
+ s = sxtysztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyjzjp_hash, iq)];
+ s = sxtyszsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxiyjzjp_hash, iq + 1)];
+ s = sxtyszsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_iy, z_jz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyizip_hash, iq)];
+ s = sxsytztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyizip_hash, iq + 1)];
+ s = sxsytztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyizjp_hash, iq)];
+ s = sxsytzsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyizjp_hash, iq + 1)];
+ s = sxsytzsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_iz, p_jp, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyjzip_hash, iq)];
+ s = sxsysztp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_ip, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_ip, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyjzip_hash, iq + 1)];
+ s = sxsysztp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_ip, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_ip, q_jq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyjzjp_hash, iq)];
+ s = sxsyszsp*tq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_jp, q_iq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_jp, q_iq);
+
+ mp = &RTable[Hash1dRTableIndex(jxjyjzjp_hash, iq + 1)];
+ s = sxsyszsp*sq;
+ result[X] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Y] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_jp, q_jq);
+ mp += 8;
+ result[Z] += INCRSUMP5(mp, s, x_jx, y_jy, z_jz, p_jp, q_jq);
+
+}
+
+
// Note that the value of NoiseEntries must be a power of 2. This
// is because bit masking using (NoiseEntries-1) is used to rescale
// the input values to the noise function.
@@ -1042,6 +1430,38 @@
}
}
+void D5Turbulence(VECTOR result, const VECTOR EPoint, const TURB *Turb)
+{
+ DBL Omega, Lambda;
+ int i;
+ DBL l, o;
+ VECTOR value, temp;
+ int Octaves=Turb->Octaves;
+
+ result[X] = result[Y] = result[Z] = 0.0;
+ value[X] = value[Y] = value[Z] = 0.0;
+
+ D5Noise(result, EPoint, Turb->Hyper);
+
+ l = Lambda = Turb->Lambda;
+ o = Omega = Turb->Omega;
+
+ for (i = 2; i <= Octaves; i++)
+ {
+ VScale(temp,EPoint,l);
+
+ D5Noise(value, temp, Turb->Hyper);
+ result[X] += o * value[X];
+ result[Y] += o * value[Y];
+ result[Z] += o * value[Z];
+ if (i < Octaves)
+ {
+ l *= Lambda;
+ o *= Omega;
+ }
+ }
+}
+
/*****************************************************************************
@@ -1799,6 +2219,7 @@
{
Noise = OriNoise;
DNoise = OriDNoise;
+ D5Noise = OriD5Noise;
}
cpu_detected = true;
@@ -2436,3 +2857,4 @@
}
+
diff -ur povray-3.7.0.RC7/source/backend/texture/texture.h povray-3.7.0.RC7.5dturb/source/backend/texture/texture.h
--- povray-3.7.0.RC7/source/backend/texture/texture.h 2012-03-15 16:19:43.000000000 -0700
+++ povray-3.7.0.RC7.5dturb/source/backend/texture/texture.h 2013-09-25 12:12:09.197712246 -0700
@@ -148,9 +148,11 @@
#else
INLINE_NOISE DBL Noise (const VECTOR EPoint, int noise_generator);
INLINE_NOISE void DNoise (VECTOR result, const VECTOR EPoint);
+INLINE_NOISE void D5Noise (VECTOR result, const VECTOR EPoint);
#endif
DBL Turbulence (const VECTOR EPoint, const TURB *Turb, int noise_generator);
void DTurbulence (VECTOR result, const VECTOR EPoint, const TURB *Turb);
+void D5Turbulence (VECTOR result, const VECTOR EPoint, const TURB *Turb);
DBL cycloidal (DBL value);
DBL Triangle_Wave (DBL value);
void Transform_Textures (TEXTURE *Textures, const TRANSFORM *Trans);
@ze-
Copy link
Author

ze- commented Sep 25, 2013

i have no idea how technically correct it is, i'm surprised it works but it seems to work as desired!
also, since this is likely slower and may also give different results from default, perhaps it should be selected over the normal 3D version only when the 'hyper' keyword is given? or something?
see https://gist.github.com/ze-/6707593 for an example loopable rendering and code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment