gpujs / gpujs/gpu.js

Interest in specifying "Offsets" to the library as a conveinence function.

Offen
#563 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
15.5k
Forks
663
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I came to Robert with a question about the possibility of adding an offset to the raw input data as a convenience = efficiency function of gpu.js. For example, when using graphical mode, and drawing a image composited out of many other images (my use case) It could be useful to simply offset the input with something like.

`kernel.setOutput({image1:[10, 10], image2:[0, 0]})`

To give an optional x/y offset for each placed image.

My first attempt at this involved trying to offset the data when loading images in webgl (in /backend/web-gl2/kernel-value/html-image-array.js, line 53, there are offsets and widths that can be set.) This worked well, but unfortunately due to a limitation in webgl, It only works with positive offsets, not negative ones. (there was a workaround here, but because it uses a canvas it might be too slow: https://stackoverflow.com/questions/20930466/webgl-is-there-an-efficient-way-to-upload-only-part-of-an-image-canvas-as-a-tex)

In response to this limitation Robert suggested just modifying the kernel function like so: https://gist.github.com/robertleeplummerjr/26796385d415a928a6f060ef5e6e0310

In this case the offset functionality is not provided by the gpu.js library, and required that the user add a modest amount of extra lines to their kernel. The question came up of whether it would make sense to include this type of function wrapper in general in gpu.js, or it user should just write it manually like shown if they need it.

Is there any interest in providing an offsets type of option to gpu.js image (or other) inputs to avoid user having to do manual bound checks and index adjustment like in the example? If so I may look into creating the api...

![A GIF or MEME to give some spice of the internet](https://github.com/davidlyons/threejs-intro/blob/master/images/300.jpg?raw=true)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit /backend/web-gl2/kernel-value/html-image-array.js etwa ab Zeile 53 und prüfe das verlinkte Kernel-Wrapper-Gist. Vergleiche, wie Bildeingaben und Offsets im Grafikmodus behandelt werden, einschließlich der genannten Einschränkung für negative Offsets. Als abgeschlossen gilt die Vereinbarung über API-Design und Implementierungsumfang für optionale Bild-Offsets sowie Tests, die das beabsichtigte Verhalten abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
computer-graphics
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.