# Need help!

This topic is 3959 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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;
}


I need something more like this:
float rsin(float x, float y, float seed)
{
????...
return value;
}



##### Share on other sites
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?

##### Share on other sites
Quote:
 Original post by grhodes_at_workA 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.

##### Share on other sites
Just going to bump this one last time I really cant figure it out -_-"

##### Share on other sites
Quote:
 Original post by Leo_E_49Perlin NoiseDescription

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633662
• Total Posts
3013229
×