-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLSL-Terms.txt
55 lines (39 loc) · 2.27 KB
/
GLSL-Terms.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
- C-like language
Similar syntax and model.
Suited for graphics (vector and matrix types are built into the language) and parallel execution (designed to run on massively parallel implementations - shader invocations).
Exception not support.
Function overloading support.
- Data types
Scalar
bool: true / false
float: single-precision floating point number (32 bit).
double: double-precision floating point number (64 bit).
int: signed integer (32 bit - 1 bit for sign; [- 2 147 483 648, 2 147 483 647]). Wrap if overflow.
uint: unsigned integer (32 bit; [0, 4 294 967 295]). Wrap if overflow.
Vector
As an array.
By size: vec2, vec3, and vec4.
Support all scalar types; require name decorator - prefix - if not float (bool - b; double - d; int - i; uint - u) e.g. bvec2, dvec2, ivec2, or uvec2.
Access: by index (array-like) vs. by component (xyzw; rgba; stpq) - allow swizzling.
Operations
Vector-Scalar: multiplication (*), and division (/).
Vector-Vector: addition (+), substraction (-), multiplication (component-wise), and division (component-wise).
Matrix
As an array of vectors (columns) or two-dimensional array.
By size: (square) mat2, mat3, and mat4; (non-square) mat2x3, mat2x4, mat3x2, mat3x4, mat4x2, and mat4x3.
Support only floating point scalar types e.g. dmat2, dmat3x4, or dmat4x2.
Access: first component only by index; second component like a vector.
Operations
Matrix-Scalar: multiplication, and division.
Matrix-Vector: multiplication.
Vector-Vector: addition, substraction, multiplication, and division (component-wise).
Structure
Syntax: "struct structure_name { ... };"
Support (as field) all scalar types, all vector and matrix types, other structures, and arrays (of any type).
Access by component (field).
Array
Syntax: "element_type var_name[var_size];" vs. "element_type[var_size] var_name;" (allow implicit type - usable as return value in a function - and its constructor definition)
Special method (member function): ".length
Support (as element type) all scalar types, all vector and matrix types, other structures, and arrays (not official support for multidimensional array).
Access by index.
Other opaque data types: represent other data structures (e.g. sampler / image for textures).