Created
September 2, 2018 19:20
-
-
Save jt0dd/d0407280d073a831a50cca2f25328f5c to your computer and use it in GitHub Desktop.
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
const gpuTexturize = graphics.gpu | |
.createKernel(function(buffer, width) { | |
var channel = buffer[((this.thread.y * width * 4) // calculate the index on the flat array buffer for the y index | |
+ this.thread.x * 4) // add the x which is the current row | |
+ this.thread.z] // add z which is the current channel | |
return channel; | |
}) | |
.setOutput([image.width, image.height, 4]); | |
// would expect this to output [[[255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], ... and so on for each width pixel ... ], [...], [...], [...], [...], [...], [...] ... and so on for each height pixel ... ] | |
// (it doesnt work this way, the output here would actually be [[], [], [], []] structured by the z axis which is the color channel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment