Created
March 19, 2019 18:27
-
-
Save robertleeplummerjr/7593a0b8c929d5ea7dfc824789bc7fcf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const { GPU } = require('gpu.js'); | |
const gpu = new GPU(); | |
gpu.addFunction(function hash3D(x, y, z) { | |
const ix = (Math.floor(x/this.output.x)) + 1e5, | |
iy = (Math.floor(y/this.output.x)) + 1e5, | |
iz = (Math.floor(z/this.output.x)) + 1e5; | |
return ((ix * 10223) + (iy * 12919) + (iz * 16127)) % 1e6; | |
}); | |
const kernel = gpu.createKernel(function() { | |
return hash3D(this.thread.x, this.thread.y, this.thread.z); | |
}, { output: [2, 2, 2] }); | |
console.log(kernel()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment