vec4
vec4 is a core node used to create and represent a vector of four floating-point numbers. Its primary use is to define RGBA colors with an alpha channel for transparency. It also serves as the basis for homogeneous coordinates in 3D math and as a general-purpose four-channel data container.
Core Advantages
Represents color with transparency. The fourth component (alpha) of a `vec4` enables control over an object's opacity, making it an indispensable tool for creating semi-transparent visual effects like glass, water, UI elements, and fades.
Common Uses
Defining material color with transparency
Texture sampling output
Data packing
How to adjust
Adjusting the constructor arguments of `vec4` directly changes its output. When used as a color, modifying the first three components (R, G, B) changes its hue, while adjusting the fourth component (Alpha) changes the material's opacity. For example, lowering the alpha from 1.0 to 0.5 will make an opaque object semi-transparent.
Code Examples
1// Combine a vec3 color and a float opacity to create a vec4
2const finalRGBA = vec4( rgbColor_node, opacity_node );
3
4// The color and opacity can then be extracted separately
5const colorPart = finalRGBA.rgb; // results in a vec3
6const alphaPart = finalRGBA.a; // results in a float