News for hackers. Stuff that matters.
Re:Show HN: Metaballs by skeoh on Tuesday October 17, 2017 @05:46PM (#15495258)
I believe 2D canvas rendering is performed on the CPU rather than the GPU.
Re:Show HN: Metaballs by Franciscouzo on Tuesday October 17, 2017 @06:34PM (#15495541)
You wouldn't use a 2d context, you can use WebGL shaders instead. Besides that, most operations on a 2d context are performed on the GPU.
Re:Show HN: Metaballs by fyrstenberg on Wednesday October 18, 2017 @01:35PM (#15501120)
Most is done on the GPU nowadays - only getImageData() and putImageData() has to go via the CPU.

You can BTW also "cheat" your way to meta-balls: https://stackoverflow.com/questions/17177748/increasing-real...

Re:Show HN: Metaballs by ZenPsycho on Tuesday October 17, 2017 @06:17PM (#15495435)
much of it is offloaded to the GPU by recent browsers
Re:Show HN: Metaballs by slavik81 on Tuesday October 17, 2017 @07:01PM (#15495675)
The important bit is getting the metaball function into the fragment shader. I'm not really a web guy, but I know you can do that with WebGL.

For a canvas with a more limited API, you can still do it if images are GPU accelerated with a composite mode like "lighter". If that's the case, you can do basically the same thing by first rendering the metaball function to an image once, and then drawing that image for each metaball. Doing it via an image introduces extra aliasing artifacts, but might get around the API limitations.

Edit: I suppose you would still want to find a GPU-accelerated threshold function for the step after that.