VECTOR TYPES

2-component boolean vector

bool2 a = bool2(true, false);
bool2 b = bool2(true);
bool2 c = aBool3.xz;

A boolean vector type with two components.

There are several ways to initialize a vector:

bool2 d = bool2(aInt2);

The vector constructors can be used to cast between different vector types.

3-component boolean vector

bool3 a = bool3(true, false, true);
bool3 b = bool3(true);
bool3 c = bool3(true, aBool2);
bool3 c = aBool4.zyx;

A boolean vector type with three components.

There are several ways to initialize a vector:

bool3 d = bool3(aInt3);

The vector constructors can be used to cast between different vector types.

4-component boolean vector

bool4 a = bool4(true, false, true, false);
bool4 b = bool4(true);
bool4 c = bool4(true, aBool2, false);
bool4 d = aBool2.xxyy;

A boolean vector type with four components.

There are several ways to initialize a vector:

bool4 d = bool4(aFloat4);

The vector constructors can be used to cast between different vector types.

2-component integer vector

int2 a = int2(1, 1);
int2 b = int2(1);
int2 c = aInt3.xz;

A signed integer vector type with two components (32 bit per component). Analogous vector types based on the scalar types char, uchar, short, ushort, uint, long and ulong are available.

There are several ways to initialize a vector:

int2 d = int2(aFloat2);

The vector constructors can be used to cast between different vector types.

3-component integer vector

int3 a = int3(1, 0, 1);
int3 b = int3(1);
int3 c = int3(1, aInt2);
int3 c = aInt4.zyx;

A signed integer vector type with three components (32 bit per component).

Analogous vector types based on the scalar types char, uchar, short, ushort, uint, long and ulong are available.

There are several ways to initialize a vector:

int3 d = int3(aBool3);

The vector constructors can be used to cast between different vector types.

4-component integer vector

int4 a = int4(1, 0, 1, 0);
int4 b = int4(1);
int4 c = int4(1, aInt2, 0);
int4 d = aInt2.xxyy;

A signed integer vector type with three components (32 bit per component).

Analogous vector types based on the scalar types char, uchar, short, ushort, uint, long and ulong are available.

There are several ways to initialize a vector:

int4 d = int4(aFloat4);

The vector constructors can be used to cast between different vector types.

2-component floating point vector

float2 a = float2(1.0, 0.0);
float2 b = float2(1.0);
float2 c = aFloat3.xz;

A single precision, floating point vector type with two components. An analogous vector type based on the scalar type half is available.

There are several ways to initialize a vector:

float2 d = float2(aBool2);

The vector constructors can be used to cast between different vector types.

3-component floating point vector

float3 a = float3(1.0, 0.0, 1.0);
float3 b = float3(1.0);
float3 c = float3(1.0, aFloat2);
float3 c = aFloat4.zyx;

A single precision, floating point vector type with three components. An analogous vector type based on the scalar type half is available.

There are several ways to initialize a vector:

float3 d = float3(aBool3);

The vector constructors can be used to cast between different vector types.

4-component floating point vector

float4 a = float4(1.0, 0.0, 1.0, 0.0);
float4 b = float4(1.0);
float4 c = float4(1.0, aFloat2, 0.0);
float4 d = aFloat2.xxyy;

A single precision, floating point vector type with four components. An analogous vector type based on the scalar type half is available.

There are several ways to initialize a vector:

float4 d = float4(aInt4);

The vector constructors can be used to cast between different vector types.