Created
September 2, 2018 13:50
-
-
Save jt0dd/3ce8831420e8aaa75a8c9b9c8add6bb4 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 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