gpu-io
- HALF_FLOAT
- FLOAT
- UNSIGNED_BYTE
- BYTE
- UNSIGNED_SHORT
- SHORT
- UNSIGNED_INT
- INT
- BOOL
- UINT
- NEAREST
- LINEAR
- CLAMP_TO_EDGE
- REPEAT
- RGB
- RGBA
- GLSL3
- GLSL1
- WEBGL2
- WEBGL1
- EXPERIMENTAL_WEBGL
- EXPERIMENTAL_WEBGL2
- PRECISION_LOW_P
- PRECISION_MEDIUM_P
- PRECISION_HIGH_P
- BOUNDARY_TOP
- BOUNDARY_BOTTOM
- BOUNDARY_LEFT
- BOUNDARY_RIGHT
- GPULayerArray
- GPULayerType
- GPULayerNumComponents
- GPULayerFilter
- GPULayerWrap
- GPULayerState
- GPULayerRange
- GPULayerRegion
- ImageFormat
- ImageType
- GLSLVersion
- GLSLPrecision
- UniformType
- UniformValue
- UniformParams
- CompileTimeConstants
- ErrorCallback
- BoundaryEdge
- copyProgram
- addLayersProgram
- addValueProgram
- multiplyValueProgram
- setValueProgram
- setColorProgram
- zeroProgram
- renderRGBProgram
- renderAmplitudeProgram
- renderSignedAmplitudeProgram
- isWebGL2
- isWebGL2Supported
- isHighpSupportedInVertexShader
- isHighpSupportedInFragmentShader
- getVertexShaderMediumpPrecision
- getFragmentShaderMediumpPrecision
• Const HALF_FLOAT: "HALF_FLOAT"
Half float data type.
• Const FLOAT: "FLOAT"
Float data type.
• Const UNSIGNED_BYTE: "UNSIGNED_BYTE"
Unsigned byte data type.
• Const BYTE: "BYTE"
Byte data type.
• Const UNSIGNED_SHORT: "UNSIGNED_SHORT"
Unsigned short data type.
• Const SHORT: "SHORT"
Short data type.
• Const UNSIGNED_INT: "UNSIGNED_INT"
Unsigned int data type.
• Const INT: "INT"
Int data type.
• Const BOOL: "BOOL"
Boolean data type (GPUProgram uniforms only).
• Const UINT: "UINT"
Unsigned int data type (GPUProgram uniforms only).
• Const NEAREST: "NEAREST"
Nearest texture filtering.
• Const LINEAR: "LINEAR"
Linear texture filtering.
• Const CLAMP_TO_EDGE: "CLAMP_TO_EDGE"
Clamp to edge wrapping (no wrapping).
• Const REPEAT: "REPEAT"
Repeat/periodic wrapping.
• Const RGB: "RGB"
RGB image format.
• Const RGBA: "RGBA"
RGBA image format.
• Const GLSL3: "300 es"
GLSL version 300 (WebGL2 only).
• Const GLSL1: "100"
GLSL version 100 (WebGL1 and WebGL2).
• Const WEBGL2: "webgl2"
WebGL2 context ID.
• Const WEBGL1: "webgl"
WebGL1 context ID.
• Const EXPERIMENTAL_WEBGL: "experimental-webgl"
Experimental WebGL context ID.
• Const EXPERIMENTAL_WEBGL2: "experimental-webgl2"
Experimental WebGL context ID.
• Const PRECISION_LOW_P: "lowp"
GLSL lowp precision declaration.
• Const PRECISION_MEDIUM_P: "mediump"
GLSL mediump precision declaration.
• Const PRECISION_HIGH_P: "highp"
GLSL highp precision declaration.
• Const BOUNDARY_TOP: "BOUNDARY_TOP"
• Const BOUNDARY_BOTTOM: "BOUNDARY_BOTTOM"
• Const BOUNDARY_LEFT: "BOUNDARY_LEFT"
• Const BOUNDARY_RIGHT: "BOUNDARY_RIGHT"
Ƭ GPULayerArray: Float32Array | Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array
GPULayer array types.
Ƭ GPULayerType: typeof HALF_FLOAT | typeof FLOAT | typeof UNSIGNED_BYTE | typeof BYTE | typeof UNSIGNED_SHORT | typeof SHORT | typeof UNSIGNED_INT | typeof INT
GPULayer data types.
Ƭ GPULayerNumComponents: 1 | 2 | 3 | 4
GPULayer numComponents options.
Ƭ GPULayerFilter: typeof LINEAR | typeof NEAREST
GPULayer filter/interpolation types.
Ƭ GPULayerWrap: typeof REPEAT | typeof CLAMP_TO_EDGE
GPULayer wrap types.
Ƭ GPULayerState: Object
The WebGLTexture corresponding to a GPULayer buffer (e.g. currentState or lastState). This data structure also includes a reference back to the GPULayer that it originated from.
| Name | Type |
|---|---|
texture |
WebGLTexture |
layer |
GPULayer |
Ƭ GPULayerRange: Object
| Name | Type |
|---|---|
start |
number |
end |
number |
Ƭ GPULayerRegion: Object
| Name | Type |
|---|---|
x |
number |
y |
number |
width |
number |
height |
number |
Ƭ ImageFormat: typeof RGB | typeof RGBA
Image formats for GPULayer.initFromImage().
Ƭ ImageType: typeof UNSIGNED_BYTE | typeof FLOAT | typeof HALF_FLOAT
Image types for GPULayer.initFromImage().
Ƭ GLSLVersion: typeof GLSL1 | typeof GLSL3
GLSL available versions.
Ƭ GLSLPrecision: typeof PRECISION_LOW_P | typeof PRECISION_MEDIUM_P | typeof PRECISION_HIGH_P
GLSL available precision declarations.
Ƭ UniformType: typeof FLOAT | typeof INT | typeof UINT | typeof BOOL
GPUProgram uniform types.
Ƭ UniformValue: boolean | boolean[] | number | number[]
GPUProgram uniform values.
Ƭ UniformParams: Object
GPUProgram uniform parameters.
| Name | Type |
|---|---|
name |
string |
value |
UniformValue |
type |
UniformType |
Ƭ CompileTimeConstants: Object
Object containing compile time #define constants for GPUProgram fragment shader.
▪ [key: string]: string
Ƭ ErrorCallback: (message: string) => void
▸ (message): void
| Name | Type |
|---|---|
message |
string |
void
Ƭ BoundaryEdge: typeof BOUNDARY_TOP | typeof BOUNDARY_BOTTOM | typeof BOUNDARY_LEFT | typeof BOUNDARY_RIGHT
▸ copyProgram(composer, params): GPUProgram
Init GPUProgram to copy contents of one GPULayer to another GPULayer.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the input/output. |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the input/output. |
▸ addLayersProgram(composer, params): GPUProgram
Init GPUProgram to add several GPULayers together.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the inputs/output. |
params.components? |
string |
Component(s) of inputs to add, defaults to 'xyzw. |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.numInputs? |
number |
The number of inputs to add together, defaults to 2. |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the inputs/output. |
▸ addValueProgram(composer, params): GPUProgram
Init GPUProgram to add uniform "u_value" to a GPULayer.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the input/output (we assume "u_value" has the same type). |
params.value |
number | number[] |
Initial value to add, if value has length 1 it will be applied to all components of GPULayer. Change this later using uniform "u_value". |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the input/output/"u_value". |
▸ multiplyValueProgram(composer, params): GPUProgram
Init GPUProgram to multiply uniform "u_value" to a GPULayer.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the input/output (we assume "u_value" has the same type). |
params.value |
number | number[] |
Initial value to multiply, if value has length 1 it will be applied to all components of GPULayer. Change this later using uniform "u_value". |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the input/output/"u_value". |
▸ setValueProgram(composer, params): GPUProgram
Init GPUProgram to set all elements in a GPULayer to uniform "u_value".
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the output (we assume "u_value" has same type). |
params.value |
number | number[] |
Initial value to set, if value has length 1 it will be applied to all components of GPULayer. Change this later using uniform "u_value". |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the output/"u_value". |
▸ setColorProgram(composer, params): GPUProgram
Init GPUProgram to set all elements in a GPULayer to uniform "u_value".
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the output. |
params.color? |
number[] |
Initial color as RGB in range [0, 1], defaults to [0, 0, 0]. Change this later using uniform "u_color". |
params.opacity? |
number |
Initial opacity in range [0, 1], defaults to 1. Change this later using uniform "u_opacity". |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the output/uniforms. |
▸ zeroProgram(composer, params): GPUProgram
Init GPUProgram to zero output GPULayer.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
▸ renderRGBProgram(composer, params): GPUProgram
Init GPUProgram to render 3 component GPULayer as RGB.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the input. |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.scale? |
number |
Scaling factor, defaults to 1. Change this later using uniform "u_scale". |
params.opacity? |
number |
Opacity, defaults to 1. Change this later using uniform "u_opacity". |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the input. |
▸ renderAmplitudeProgram(composer, params): GPUProgram
Init GPUProgram to render RGBA amplitude of an input GPULayer's components, defaults to grayscale rendering and works for scalar and vector fields.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the input. |
params.components? |
string |
Component(s) of input GPULayer to render, defaults to 'xyzw'. |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.scale? |
number |
Scaling factor, defaults to 1. Change this later using uniform "u_scale". |
params.opacity? |
number |
Opacity, defaults to 1. Change this later using uniform "u_opacity". |
params.colorMax? |
number[] |
RGB color for amplitude === scale, scaled to [0,1] range, defaults to white. Change this later using uniform "u_colorMax". |
params.colorMin? |
number[] |
RGB color for amplitude === 0, scaled to [0,1] range, defaults to black. Change this later using uniform "u_colorMin". |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the input. |
▸ renderSignedAmplitudeProgram(composer, params): GPUProgram
Init GPUProgram to render signed amplitude of an input GPULayer to linearly interpolated colors.
| Name | Type | Description |
|---|---|---|
composer |
GPUComposer |
The current GPUComposer. |
params |
Object |
Program parameters. |
params.type |
GPULayerType |
The type of the input. |
params.component? |
"x" | "y" | "z" | "w" |
Component of input GPULayer to render, defaults to "x". |
params.name? |
string |
Optionally pass in a GPUProgram name, used for error logging. |
params.scale? |
number |
Scaling factor, defaults to 1. Change this later using uniform "u_scale". |
params.bias? |
number |
Bias for center point of color range, defaults to 0. Change this later using uniform "u_bias". |
params.opacity? |
number |
Opacity, defaults to 1. Change this later using uniform "u_opacity". |
params.colorMax? |
number[] |
RGB color for amplitude === bias + scale, scaled to [0,1] range, defaults to red. Change this later using uniform "u_colorMax". |
params.colorMin? |
number[] |
RGB color for amplitude === bias + scale, scaled to [0,1] range, defaults to blue. Change this later using uniform "u_colorMin". |
params.colorCenter? |
number[] |
RGB color for amplitude === bias, scaled to [0,1] range, defaults to white. Change this later using uniform "u_colorCenter". |
params.precision? |
GLSLPrecision |
Optionally specify the precision of the input. |
▸ isWebGL2(gl): boolean
Returns whether a WebGL context is WebGL2. This code is pulled from https://github.com/mrdoob/three.js/blob/master/src/renderers/webgl/WebGLCapabilities.js
| Name | Type | Description |
|---|---|---|
gl |
WebGLRenderingContext | WebGL2RenderingContext |
WebGL context to test. |
boolean
- true if WebGL2 context, else false.
▸ isWebGL2Supported(): boolean
Returns whether WebGL2 is supported by the current browser.
boolean
- true if WebGL2 is supported, else false.
▸ isHighpSupportedInVertexShader(): boolean
Detects whether highp precision is supported in vertex shaders in the current browser.
boolean
- true is highp is supported in vertex shaders, else false.
▸ isHighpSupportedInFragmentShader(): boolean
Detects whether highp precision is supported in fragment shaders in the current browser.
boolean
- true is highp is supported in fragment shaders, else false.
▸ getVertexShaderMediumpPrecision(): "highp" | "mediump"
Returns the actual precision of mediump inside vertex shader. From https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html
"highp" | "mediump"
- Vertex shader mediump precision.
▸ getFragmentShaderMediumpPrecision(): "highp" | "mediump"
Returns the actual precision of mediump inside fragment shader. From https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html
"highp" | "mediump"
- Fragment shader supported mediump precision.