Other extensions

Vector type extensions

Two and four-dimensional vectors are available by including vector2.h or vector4.h respectively.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
// vector2 is a 2D vector
struct vector2
{
    float x;
    float y;
};


// vector4 is a 4D vector
struct vector4
{
    float x;
    float y;
    float z;
    float w;
};

The negation unary operator is defined in addition to these binary operators:

1
+, -, *, /, ==, !=

Most of the stdosl functions are also defined to match vector.

Color type extensions

Single color channel plus alpha and RGB plus alpha color types are available by including color2.h or color4.h respectively.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// color2 is a single color channel + alpha
struct color2
{
    float r;
    float a;
};

// color4 is a color + alpha
struct color4
{
    color rgb;
    float a;
};

The negation unary operator is defined in addition to these binary operators:

1
+, -, *, /, ==, !=

Most of the stdosl functions are also defined to match color.

3x3 square matrix extension

3x3 matrix is available by including matrix33.h.

1
2
3
4
struct matrix33
{
    matrix m;
};

The following functions are defined:

1
2
3
4
5
6
7
8
int isValidAs33(matrix m44);
matrix matrix33To44 (matrix33 m33);
matrix33 matrix44To33 (matrix m44);
float determinant (matrix33 a);
matrix33 transpose(matrix33 a);
point transform(matrix33 a, point b);
vector transform(matrix33 a, vector b);
normal transform(matrix33 a, normal b);

The negation unary operator is defined in addition to these binary operators:

1
*, /, ==, !=

Last update: March 5, 2024