Jump to content

noise using VEX and for loop


bhaveshpandey

Recommended Posts

I'm trying to write a VEX script which would apply noise to a geometry using a for loop..(I'm a newbie in VEX so please excuse my lack of knowledge :) )

basically what I intend to do is to Layer the noise affecting a geometry using its Point numbers as counters in the FOR loop and multiplying it with a Amplitude gain and Frequency gain parameter so that its increasing/decreasing for every iteration (which would thus give me good layer of noise applied on top of each other to a geometry.

here's the scrip so far:

float amp, freq, again, fgain, sum; 
int i;
for(i=0; i<npts; i++)
	{
		float noise;
		float AMP;
		float FREQ;
		float AMP= amp*again;
		float FREQ=freq*fgain;
		noise= AMP* noise(FREQ*P);
		sum+= noise;
	}


Sop
Sop1(amp=0.5, freq=2, again=o.5, fgain=0.5)
{
sum;
}

I have declared the variables etc..but i'm getting a syntax error in the first line..but I cant see anything wrong with it??

Also I'm not sure of how to execute it in the sop level...so just to check I just called it in the SOP level..but I'm not really sure about it....

could someone help me with this..

Thanks.

PS: here's a .vfl file

Edited by bhaveshpandey
Link to comment
Share on other sites

There are quite a few things wrong with your vex code.

Try this:

//pragmas for your parameters

#pragma hint again hidden
#pragma hint fgain hidden

//if you like to use some custom functions put them here


//the very body of the sop

Sop
Sop1(float amp=0.5, freq=2, again=0.5, fgain=0.5;) // your user parameters.
{

vector PP; //temporary P
float mynoise=0, sum=0;         
int i;

for(i=0; i<Npt; i++)
        {  
        mynoise= amp* noise(freq*P);
        sum = mynoise;
        }

PP = set(P.x, P.y+sum, P.z);
//do something to attributes to see the result:)
P = PP;                           
}

Have a look at houdini help, it's very good.

Edited by peliosis
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...