Skip to content

GpuVec4

1 min read

Import: import system.gpu;

This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation. Shader-only declarations can be used only inside shader entry points and helpers reached from them; using them elsewhere is a compile error.

GpuVec4

A vector of four floats, laid out like a GPU float4, for RGBA colors, clip-space positions and homogeneous coordinates. Use it on the CPU and in shaders alike. Arithmetic works component by component, and a float operand applies to every component.

public struct GpuVec4

x

The first component, or red.

public x: float

y

The second component, or green.

public y: float

z

The third component, or blue.

public z: float

w

The fourth component, or alpha.

public w: float

constructor

Creates the vector (x, y, z, w).

public constructor(x: float, y: float, z: float, w: float)

constructor

Creates a vector with every component equal to value.

public constructor(value: float)

xy

The first two components.

public get xy(): GpuVec2

xyz

The first three components.

public get xyz(): GpuVec3

dot

The dot product.

public fun dot(other: GpuVec4): float

length

The vector's Euclidean length.

public fun length(): float

normalize

The vector scaled to length 1. A zero vector gives non-finite components.

public fun normalize(): GpuVec4