Jump to content

Curl Noise functions in voplib.h


Poetsofthefall

Recommended Posts

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;
Link to comment
Share on other sites

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 by anim
  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...