Basically I made a bit of code that generates a pseudo-random sine waves based on a value and a seed value. But I need something like this in 2D so I can generate perlin noise on the fly here is the code I made:
float rsin(float x, float seed)
{
float a = myrand(int(x),seed);
float b = myrand(int(x)+1,seed);
float c = ((x-int(x))*3.1415)-1.57;
float d = ((sin(c)*((a-b)/2))+a)-((a-b)/2);
return d;
}
A word of advice about using random number generators in general...I wouldn't pass the "seed" value in every time you need to sample a point. That would reset the algorithm every time and would defeat the "randomness." If you do what you're doing, and look at the results of, say, 1000 uniform samples, you would find that you aren't actually getting a uniform distribution. Set it once and let the underlying algorithm take it from there. The only time to reset the seed is, say at the beginning of some simulation, if you need to reproduce the exact numerical results from prior simulation.
As for your question, have you seen Perlin's article in the book GPU Gems?
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Quote:Original post by grhodes_at_work A word of advice about using random number generators in general...I wouldn't pass the "seed" value in every time you need to sample a point. That would reset the algorithm every time and would defeat the "randomness." If you do what you're doing, and look at the results of, say, 1000 uniform samples, you would find that you aren't actually getting a uniform distribution. Set it once and let the underlying algorithm take it from there. The only time to reset the seed is, say at the beginning of some simulation, if you need to reproduce the exact numerical results from prior simulation.
As for your question, have you seen Perlin's article in the book GPU Gems?
Dont have money for books, I only get info form the web... and thats just how my function works I always input the same value anyways.
This is your life, and it's ending one minute at a time. - Fight club