Skip to content

Instantly share code, notes, and snippets.

@doxas
Created June 13, 2015 23:54
Show Gist options
  • Save doxas/ebeac1351053e643be43 to your computer and use it in GitHub Desktop.
Save doxas/ebeac1351053e643be43 to your computer and use it in GitHub Desktop.
#define PI 3.14159265
float perlin(vec3 p){
vec3 i = floor(p);
vec4 a = dot(i, vec3(1.0, 57.0, 21.0)) + vec4(0.0, 57.0, 21.0, 78.0);
vec3 f = cos((p - i) * PI) * (-0.5) + 0.5;
a = mix(sin(cos(a) * a), sin(cos(1.0 + a) * (1.0 + a)), f.x);
a.xy = mix(a.xz, a.yw, f.y);
return mix(a.x, a.y, f.z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment