Skip to content

Instantly share code, notes, and snippets.

@gonnavis
Last active February 17, 2021 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonnavis/6e1a58419e5835358122cb1526ece8e5 to your computer and use it in GitHub Desktop.
Save gonnavis/6e1a58419e5835358122cb1526ece8e5 to your computer and use it in GitHub Desktop.
// http://glslsandbox.com/e#61476.1
float hash( float n ){
return fract(sin(n)*1751.5453);
}
float hash1( vec2 p ){
return fract(sin(p.x+131.1*p.y)*1751.5453);
}
vec3 hash3( float n ){
return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,22578.1459123,19642.3490423));
}
vec3 random3(vec3 c) {
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
vec3 r;
r.z = fract(512.0*j);
j *= .125;
r.x = fract(512.0*j);
j *= .125;
r.y = fract(512.0*j);
return r-0.5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment