Skip to content

Instantly share code, notes, and snippets.

@alexesDev
Created October 16, 2012 10:26
Show Gist options
  • Select an option

  • Save alexesDev/3898534 to your computer and use it in GitHub Desktop.

Select an option

Save alexesDev/3898534 to your computer and use it in GitHub Desktop.
Noise
float discreteNoise( uint32 x )
{
uint32 t;
x=(x<<13)^x;
t = x*790169+x*x*x*15731 + 1376312588;
return (float)( 1.0-(t%1073741824)/536870912.0 );
}
float discreteNoise(uint32 x,uint32 y )
{
uint32 t;
x=(x<<13)^x;
y=(y<<13)^y;
t = x*790169+x*x*x*15731
+ y*789221+y*y*y*16057
+ x*y*209123
+ 1376312588;
return (float)( 1.0-(t%1073741824)/536870912.0 );
}
float discreteNoise(uint32 x,uint32 y, uint32 z )
{
uint32 t;
x=(x<<13)^x;
y=(y<<13)^y;
z=(z<<13)^z;
t = x*790169+x*x*x*15731
+ y*789221+y*y*y*16057
+ z*788317+z*z*z*15401
+ x*y*209123
+ y*z*209581
+ x*z*208501
+ x*y*z*15749
+ 1376312588;
return (float)( 1.0-(t%1073741824)/536870912.0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment