You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-3Lines changed: 22 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,8 +174,9 @@ Settings are an object used to create a `kernel` or `kernelMap`. Example: `gpu.
174
174
*`precision` or `kernel.setPrecision('unsigned' | 'single')`**New in V2!**: 'single' or 'unsigned' - if 'single' output texture uses float32 for each colour channel rather than 8
175
175
*`fixIntegerDivisionAccuracy` or `kernel.setFixIntegerDivisionAccuracy(boolean)` : boolean - some cards have accuracy issues dividing by factors of three and some other primes (most apple kit?). Default on for affected cards, disable if accuracy not required.
176
176
*`functions` or `kernel.setFunctions(object)`: array, array of functions to be used inside kernel. If undefined, inherits from `GPU` instance.
177
-
*`nativeFunctions` or `kernel.setNativeFunctions(object)`: object, defined as: `{ functionName: functionSource }`
177
+
*`nativeFunctions` or `kernel.setNativeFunctions(object)`: object, defined as: `{ name: string, source: string, settings: object }`. This is generally set via using GPU.addNativeFunction()
178
178
* VERY IMPORTANT! - Use this to add special native functions to your environment when you need specific functionality is needed.
179
+
*`injectedNative` or `kernel.setInjectedNative(string)`**New in V2!**: string, defined as: `{ functionName: functionSource }`. This is for injecting native code before translated kernel functions.
179
180
*`subKernels` or `kernel.setSubKernels(array)`: array, generally inherited from `GPU` instance.
180
181
*`immutable` or `kernel.setImmutable(boolean)`: boolean, default = `false`
181
182
*`strictIntegers` or `kernel.setStrictIntegers(boolean)`: boolean, default = `false` - allows undefined argumentTypes and function return values to use strict integer declarations.
@@ -376,6 +377,7 @@ Debugging can be done in a variety of ways, and there are different levels of de
376
377
```
377
378
* HTML Image
378
379
* Array of HTML Images
380
+
* Video Element **New in V2!**
379
381
To define an argument, simply add it to the kernel function like regular JavaScript.
const video = new document.createElement('video');
463
+
video.src = 'my/video/source.webm';
464
+
kernel(image); //note, try and use requestAnimationFrame, and the video should be ready or playing
465
+
// Result: video frame
466
+
```
467
+
450
468
## Graphical Output
451
469
452
470
Sometimes, you want to produce a `canvas` image instead of doing numeric computations. To achieve this, set the `graphical` flag to `true` and the output dimensions to `[width, height]`. The thread identifiers will now refer to the `x` and `y` coordinate of the pixel you are producing. Inside your kernel function, use `this.color(r,g,b)` or `this.color(r,g,b,a)` to specify the color of the pixel.
@@ -633,6 +651,7 @@ Types that can be used with GPU.js are as follows:
0 commit comments