vec2
vec2 is a fundamental shader node used to create and represent a two-component vector of floating-point numbers. It's primarily used for handling data like UV texture coordinates, screen-space positions, 2D offsets, or directions.
Core Advantages
Flexible data construction. The vec2 node can create 2D vectors in multiple ways: by combining two separate floats, expanding from a single float (e.g., `vec2(0.5)` becomes `vec2(0.5, 0.5)`), or extracting components from higher-dimension vectors, making it a core tool for building and converting 2D data.
Common Uses
UV coordinate manipulation (panning, scaling)
Procedural 2D patterns and SDFs (Signed Distance Fields)
Constructing higher-dimension vectors
How to adjust
Adjusting the constructor arguments of a `vec2` directly changes its x and y output values. The vector's purpose determines the final effect. For instance, if the vector is used as a UV offset, changing `vec2(0.1, 0)` to `vec2(0, 0.1)` will shift the texture's movement from horizontal to vertical.
Code Examples
1// Create a vec2 offset vector from two separate float nodes
2const offset = vec2( offsetX, offsetY );
3
4// Apply the created vector to UV coordinates to achieve panning
5const pannedUVs = uv().add( offset );