vec4
vec4 is a four-component vector type used in GLSL, the OpenGL Shading Language, and in related shading languages. It represents a vector of four 32-bit floating-point numbers and is commonly used to store positions, directions, colors, or homogeneous coordinates in 3D graphics.
Each component of a vec4 is named x, y, z, and w, though the same storage is
Constructors and representations include several forms: vec4(x, y, z, w); vec4(v3, w) where v3 is a vec3;
Vector operations follow standard rules: vec4 supports addition, subtraction, scalar multiplication, and equality testing. GLSL provides
Common usage includes representing a position in homogeneous coordinates (often with w = 1.0 for points in
Example: vec4 color = vec4(1.0, 0.5, 0.0, 1.0); vec4 pos = vec4(vertex.xyz, 1.0).