Vector4
public struct Vector4A vector of four floats, used for a shader vec4 uniform that is not a colour. A colour uniform is read and written as a Color instead.
Constructors
Section titled “Constructors”Vector4
Section titled “Vector4”public Vector4(float x, float y, float z, float w);Creates a vector from its X, Y, Z and W components.
Properties you read and set
Section titled “Properties you read and set”public float X { get; set; }The first component, x in a shader vec4.
public float Y { get; set; }The second component, y in a shader vec4.
public float Z { get; set; }The third component, z in a shader vec4.
public float W { get; set; }The fourth component, w in a shader vec4.
static
public static Vector4 Zero { get; }The vector (0, 0, 0, 0).
static
public static Vector4 One { get; }The vector (1, 1, 1, 1).
Methods you call
Section titled “Methods you call”Length
Section titled “Length”public float Length();Length (magnitude) of this vector across all four components.
Normalized
Section titled “Normalized”public Vector4 Normalized();This vector scaled to length 1, keeping its direction. A zero vector returns zero rather than an error.
public float Dot(Vector4 other);Dot product with other: the sum of the products of matching components.
static
public static Vector4 Lerp(Vector4 from, Vector4 to, float weight);Linear interpolation from from to to, component by component: a weight of 0 gives from, 1 gives to and 0.5 the midpoint. The weight is not clamped, so values outside 0 to 1 carry on past either end.
Equals
Section titled “Equals”override
public override bool Equals(object obj);True when obj is a Vector4 with exactly equal components.
GetHashCode
Section titled “GetHashCode”override
public override int GetHashCode();A hash of the components, so the vector can key a dictionary or a set.
ToString
Section titled “ToString”override
public override string ToString();The vector as text, for example Vector4(1, 0, 0, 1).
Operators
Section titled “Operators”operator +
Section titled “operator +”static
public static Vector4 operator +(Vector4 a, Vector4 b);Adds two vectors component by component.
operator -
Section titled “operator -”static
public static Vector4 operator -(Vector4 a, Vector4 b);Subtracts b from a component by component.
static
public static Vector4 operator -(Vector4 a);Negates every component.
operator *
Section titled “operator *”static
public static Vector4 operator *(Vector4 a, float s);Multiplies every component of a by s.
static
public static Vector4 operator *(float s, Vector4 a);Multiplies every component of a by s.
operator /
Section titled “operator /”static
public static Vector4 operator /(Vector4 a, float s);Divides every component of a by s. Dividing by zero gives infinite or NaN components, not an error.
operator ==
Section titled “operator ==”static
public static bool operator ==(Vector4 a, Vector4 b);True when all four components are exactly equal.
operator !=
Section titled “operator !=”static
public static bool operator !=(Vector4 a, Vector4 b);True when any component differs, compared exactly.
Generated from the CRUMB source, commit fcec660d, 2026-10-29.

