Jump to content
  • Advertisement
Sign in to follow this  
EmptyVoid

Need help!

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!