Closed
Description
I'm interested in using GPU.js as a shader. Problem is, it seems to me, the shading is fairly fast, I mean, 8.2M values in a typical full screen rgba array buffer (1080 x 1920 x 4 channels = 8,294,400) get handled using a fairly high number of unoptimized operations in ~12ms, (congratz on the performance! I havent even tried using your input method yet but your documentation doesnt mention outputting as a typed array, only that this inputs the array more efficiently) but then the typed array I input to the kernel is now an untyped array in the output, and to render it I have to convert to a typed array and that is slowwww, like so:
renderer.render(scene, camera, rt); // render scene with three.js ~1ms :)
renderer.readRenderTargetPixels(rt, 0, 0, smallWidth, smallHeight, frameBuffer); // get scene as buffer ~ 1ms :)
outputBufferRaw = pixelateMatrix(frameBuffer, [width], [height], [scale], [size], [purity]); // shade the buffer ~12ms :)))
outputBuffer = new Uint8ClampedArray(outputBufferRaw); // convert the now untyped array output from kernel ~100ms :(((
output = new ImageData(outputBuffer, width, height); // create ImageData from typed array ~1ms :)
context.putImageData(output, 0, 0); // render result ~1ms :)
Maybe I'm missing something? Is there already a way to get the output as a typed array?
Metadata
Metadata
Assignees
Labels
No labels