attribute float index; //array with numbers between [1, 2500000] float inc = 3.141592653589793238462643383279 * (3.0 - sqrt(5.0)); float off = 2.0 / 2500000; float yy = index * off - 1.0 + (off / 2.0); float rr = sqrt(1.0 - yy * yy); float phi = index* inc; // big number, "5476389.695241543"-biggish vec3 fibPoint = vec3(cos(phi) * rr, yy, sin(phi) * rr); // calculates sin/cos wrong

/* short version of code from javascript */ var y = index * off - 1 + (off / 2.0); var r = Math.sqrt(1 - y * y); var phi = index * inc; var cosphi = Math.cos(phi); var sinphi = Math.sin(phi); .... .. /* throw cosphi/sinphi into the shader as attributes along with the index */ /* vertex shader */ attribute float index; attribute float sinphi; attribute float cosphi; float inc = 3.141592653589793238462643383279 * (3.0 - sqrt(5.0)); float off = 2.0 / 2500000; float yy = index * off - 1.0 + (off / 2.0); float rr = sqrt(1.0 - yy * yy); //float phi = index* inc; vec3 fibPoint = vec3(cosphi * rr, yy, sinphi * rr);