Skip to content

Instantly share code, notes, and snippets.

@jt0dd
Created September 2, 2018 13:50
Show Gist options
  • Save jt0dd/3ce8831420e8aaa75a8c9b9c8add6bb4 to your computer and use it in GitHub Desktop.
Save jt0dd/3ce8831420e8aaa75a8c9b9c8add6bb4 to your computer and use it in GitHub Desktop.
const gpu = new GPU();
const createTexture = gpu.createKernel(function() {
this.color(55, 55, 55, 255);
}).setOutput([1920,1080]).setOutputToTexture(true);
var texture1 = createTexture();
const kernel = gpu.createKernel(function() {
var pixel = this.constants.texture1[this.thread.x][this.thread.y];
var color = 0;
var channel = this.thread.z;
if (channel === 0) {
color = pixel.r;
}
if (channel === 1) {
color = pixel.g;
}
if (channel === 2) {
color = pixel.b;
}
if (channel === 3) {
color = pixel.a;
}
return color;
}, {
constants : { texture1 }
}).setOutput([1920, 1080, 4]);
const bitmap = kernel();
console.log(bitmap);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment