We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › about emulating noise() function in C++
Page Index Toggle Pages: 1
about emulating noise() function in C++ (Read 1056 times)
about emulating noise() function in C++
Oct 16th, 2006, 8:27pm
 
i was so surprised to see that my post was not appearing on the board which i posted yesterday. Anyway, let me just post my question again.

The noise() function in processing is really great. However, how can we emulate it in C++ with Opengl? Is there any existing processing library for C++?

Or, can anyone tell me how the noise() function is implemented in processing so that i can try to figure out how to write the similar function in C++?

Thanks a lot!
Re: about emulating noise() function in C++
Reply #1 - Oct 16th, 2006, 9:30pm
 
The noise() function is a variant of the coherent harmonic noise function, created by Ken Perlin. (So its called Perlin Noise) He also won an academy award for it, because it really did revolutionize the FX industry.  And since Ken is a cool guy he shared the idea and its free for everybody.

First, a good link as to how it works: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

Another:
http://www.cs.cmu.edu/~mzucker/code/perlin-noise-math-faq.html

Ken's Page:
http://mrl.nyu.edu/~perlin/


With those links you should be able to create or find a C version.  


Re: about emulating noise() function in C++
Reply #2 - Oct 16th, 2006, 10:23pm
 
Thanks a lot! I have gone through all the listed websites, however, the function i generated or, should say, copy & paste from the website, can't produce the same result as the 1-D noise() function in Processing.

What could be wrong? Is there anywhere i can fine the inside of the noise() function in Processing?
Re: about emulating noise() function in C++
Reply #3 - Oct 16th, 2006, 10:57pm
 
The code compiled by me is as following:

float smoothNoise1D( float x )
{
int xi; //integer component
float xf; //floating point component
float xs; //s-curve function result
float l0, l1; //uninterpolated values
xi = (int)x;
xf = x - (float)xi;
xs = sCurve(xf);
l0 = simpleNoise1D( xi );
l1 = simpleNoise1D( xi+1 );
return lerp1( xf, l0, xs ); //interpolate the noise values useing the s-curve value
}

float simpleNoise1D( int x )
{
x = (x<<13) ^ x;
return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) &0x7fffffff) /

1073741824.0);
}

float sCurve( float t )
{
return t*t*(3-2*t);
}

float lerp1( float t, float a, float b )
{
return a + t*( b - a );
}
Re: about emulating noise() function in C++
Reply #4 - Oct 16th, 2006, 10:59pm
 
the post was removed because it was not a processing question, it was a question about implementing the noise() function for a c++ homework assignment.

your new post is slightly more processing-related, but it appears you went straight to the board without the slightest bit of work on your own part. first, read the reference to noise():
http://processing.org/reference/noise_.html

which states the algorithm used, which can be looked up in google, if you want background. or if you want to adapt it to c++, take the processing source code, and adapt it as you see fit. but if it's not a question about processing, don't be surprised if it's removed from the board.
Re: about emulating noise() function in C++
Reply #5 - Oct 16th, 2006, 11:03pm
 
sorry, fry. can you kindly tell me where the noise() function resides in the library or the source code, i.e. how can i locate it after i install processing?

thanks a lot!
Re: about emulating noise() function in C++
Reply #6 - Oct 17th, 2006, 8:17am
 
The noise() function is a Java conversion of very fast C implementations of 1D, 2D and 3D perlin noise made by the demoscene group Farbrausch. The production in question is fr-010...

more info and source here...

FWIW in Processing the noise() function is part of the PApplet class...
Page Index Toggle Pages: 1