Created
March 14, 2013 16:30
-
-
Save joelpryde/5162828 to your computer and use it in GitHub Desktop.
GLSL Noise 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float rand( float n ) | |
{ | |
return fract(sin(n*443.23)*43758.5453); | |
} | |
float hash( float n ) | |
{ | |
return fract(sin(n)*43758.5453123); | |
} | |
float noise( in vec3 x ) | |
{ | |
vec3 p = floor(x); | |
vec3 f = fract(x); | |
f = f*f*(3.0-2.0*f); | |
float n = p.x + p.y*57.0 + 113.0*p.z; | |
float res = mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x), | |
mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y), | |
mix(mix( hash(n+113.0), hash(n+114.0),f.x), | |
mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment