bhaveshpandey Posted September 10, 2009 Share Posted September 10, 2009 (edited) 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 September 10, 2009 by bhaveshpandey Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 10, 2009 Share Posted September 10, 2009 (edited) 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 September 10, 2009 by peliosis Quote Link to comment Share on other sites More sharing options...
pencha Posted September 10, 2009 Share Posted September 10, 2009 check the Octaves param, it's available on most pre-built noises and I think it's exactly what you are trying to get. Quote Link to comment Share on other sites More sharing options...
bhaveshpandey Posted September 10, 2009 Author Share Posted September 10, 2009 @Peliosis thanks a ton mate!! i see now where I was going off.. Yep Pencha I was trying to get that done but since I started learning VEX, I thought its better to try and implement it somewhere..I have a long road ahead I guess Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.