Home

Search IconIcon to open search

Angles and rotation in GLSL

Zero starts from the right axis, positive rotation is clockwise. If we do fract(atan(y, x)) on the translated UV, we’ll get this:
|400

Matrix multiplication. See also this and this.

To summarize, if you want to apply matrix to a vector, you write it in this order, like in good ol’ math:

1
vec3 new_vector = matrix * old_vector;

You can also write it in reverse order, but that will multiply by a transposed matrix. Sadly, some_vec *= matrix will do exactly that.

# So, how to rotate something in GLSL?

1
vec2 rotated_vector = rotation_matrix * vector;