Skip to content

Instantly share code, notes, and snippets.

@gonnavis
Last active February 17, 2021 10:40
Show Gist options
  • Save gonnavis/6e1a58419e5835358122cb1526ece8e5 to your computer and use it in GitHub Desktop.
Save gonnavis/6e1a58419e5835358122cb1526ece8e5 to your computer and use it in GitHub Desktop.

Revisions

  1. gonnavis revised this gist Feb 17, 2021. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions glsl random
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,14 @@
    // 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 ){
    // http://glslsandbox.com/e#61476.1
    return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,22578.1459123,19642.3490423));
    return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,22578.1459123,19642.3490423));
    }

    vec3 random3(vec3 c) {
  2. gonnavis created this gist Jan 29, 2021.
    16 changes: 16 additions & 0 deletions glsl random
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@

    vec3 hash3( float n ){
    // http://glslsandbox.com/e#61476.1
    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;
    }