gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

Output 1D Unknown-Length Array from 2D Known-Length Array

Open c4b4d4 opened this issue 2 years ago • 3 comments

I'm trying to generate an unknown-length array, from an input image or 2D array.

I want to distribute data using a noise image, for example:

For every white pixel -> Save the position of it (x, y) and push it to an array so you end up having a Z-length array. Where Z is the number of white pixels in the noise image.

Input

Screenshot 2022-12-28 at 17 08 45

Output

[[x1, y1], [x2, y2], .... [xZ, yZ]]

In result I get all the locations of where a pixel is white.

I need to use GPU power, since noise images are huge in my use case and must be updated at least at 24 fps.

Doing math

c4b4d4 avatar Dec 28 '22 23:12 c4b4d4

This is not possible using gpu.js D:

ObliviousDonkey avatar Dec 30 '22 09:12 ObliviousDonkey

This is not possible using gpu.js D:

Is this a limit on how GPU operations work? Or just a missing feature/characteristic of the library?

c4b4d4 avatar Jan 01 '23 07:01 c4b4d4

I guess the library is missing the feature.

https://github.com/gpujs/gpu.js/#types The kernel can only return few amount of types, the length of returned array cannot be more than 3.

TrashUwU avatar Jan 01 '23 15:01 TrashUwU