Poetsofthefall 1 Posted October 8, 2019 Ahoy there!!! A quick question... I'm writing VEX noise functions but is a bit confused with Curl Noise functions. It's not like that I didnt get it. Of course I get it but is stuck in this weird functions in voplib.h. Here's what I'm stuck with.... Down below is the Code. why is xDiffNoise yDiffNoise and zDiffNoise there anyways. I couldnt find a function that's making use of it. Maybe I'm missing some. But please somebody explain it to me. Just to say... I'm writing a Curl Vex Function with all the Noise options. Thanks. noisevec = onoise(pos*freq - offset, turb, rough, atten) * amp; xDiffNoise = onoise(xDiff*freq - offset, turb, rough, atten) * amp; yDiffNoise = onoise(yDiff*freq - offset, turb, rough, atten) * amp; zDiffNoise = onoise(zDiff*freq - offset, turb, rough, atten) * amp; Share this post Link to post Share on other sites

jkunz07 187 Posted October 9, 2019 Those are used to sample finite differences of the noise, in order to find the gradient vector of the scalar noise. Share this post Link to post Share on other sites

anim 1,211 Posted October 9, 2019 (edited) On 10/8/2019 at 1:00 PM, Poetsofthefall said: why is xDiffNoise yDiffNoise and zDiffNoise there anyways. I couldnt find a function that's making use of it. I'm pretty sure you'll find where they are used if you search voplib.h for them again Edited October 9, 2019 by anim 1 Share this post Link to post Share on other sites

jkunz07 187 Posted October 9, 2019 float eps = chf('epsilon'); // Default 0.01 float magnitude = chf('magnitude'); // Default 1.0 vector p = v@P; // Noise Initial Position float freq = 1.0; // Noise Frequency vector offset = chv('offset'); // Noise Offset p = p * freq - offset; // Final Noise Position vector dx = {0, 0, 0}; dx[0] = eps; vector dy = {0, 0, 0}; dy[1] = eps; vector dz = {0, 0, 0}; dz[2] = eps; vector fxdxn; vector fxdxp; vector fxdyn; vector fxdyp; vector fxdzn; vector fxdzp; // Evaluate the noise in a local neighborhood for finite differences fxdxn = noise(p-dx); fxdxp = noise(p+dx); fxdyn = noise(p-dy); fxdyp = noise(p+dy); fxdzn = noise(p-dz); fxdzp = noise(p+dz); // Compute curl from the cross product vector curl; curl[0] = (fxdyp[2] - fxdyn[2]) - (fxdzp[1] - fxdzn[1]); curl[1] = (fxdzp[0] - fxdzn[0]) - (fxdxp[2] - fxdxn[2]); curl[2] = (fxdxp[1] - fxdxn[1]) - (fxdyp[0] - fxdyn[0]); float scale = magnitude * (1.0 / (2.0 * eps)); curl *= scale; @P += curl; If it's helpful, here's what a basic curl noise function looks like. You could replace the noise() calls with whichever scalar noise you prefer. Share this post Link to post Share on other sites

Poetsofthefall 1 Posted October 10, 2019 23 hours ago, jkunz07 said: float eps = chf('epsilon'); // Default 0.01 float magnitude = chf('magnitude'); // Default 1.0 vector p = v@P; // Noise Initial Position float freq = 1.0; // Noise Frequency vector offset = chv('offset'); // Noise Offset p = p * freq - offset; // Final Noise Position vector dx = {0, 0, 0}; dx[0] = eps; vector dy = {0, 0, 0}; dy[1] = eps; vector dz = {0, 0, 0}; dz[2] = eps; vector fxdxn; vector fxdxp; vector fxdyn; vector fxdyp; vector fxdzn; vector fxdzp; // Evaluate the noise in a local neighborhood for finite differences fxdxn = noise(p-dx); fxdxp = noise(p+dx); fxdyn = noise(p-dy); fxdyp = noise(p+dy); fxdzn = noise(p-dz); fxdzp = noise(p+dz); // Compute curl from the cross product vector curl; curl[0] = (fxdyp[2] - fxdyn[2]) - (fxdzp[1] - fxdzn[1]); curl[1] = (fxdzp[0] - fxdzn[0]) - (fxdxp[2] - fxdxn[2]); curl[2] = (fxdxp[1] - fxdxn[1]) - (fxdyp[0] - fxdyn[0]); float scale = magnitude * (1.0 / (2.0 * eps)); curl *= scale; @P += curl; If it's helpful, here's what a basic curl noise function looks like. You could replace the noise() calls with whichever scalar noise you prefer. Will check it STRAIGHT AWAY. Thanks many lot. Share this post Link to post Share on other sites