Scale
To scale a model, you multiply each of its positions by a set of scale factors. A factor greater than 1 grows the model. A factor less than 1 but greater than 0 shrinks the model. A factor of 0 collapses the model into a black hole. A negative factor flips the model.
Scaling is sometimes expressed as vector multiplication. Here position \(\mathbf{p}\) is multiplied by \(\textrm{factors}\):
$$\begin{bmatrix}p_x \\ p_y \\ p_z \end{bmatrix} \times \begin{bmatrix} \textrm{factors}_x \\ \textrm{factors}_y \\ \textrm{factors}_z \end{bmatrix} = \begin{bmatrix}p_x \times \textrm{factors}_x \\ p_y \times \textrm{factors}_y \\ p_z \times \textrm{factors}_z\end{bmatrix}$$
In GLSL, the factors are declared as a uniform and applied using the *
operator:
uniform vec3 factors;
in vec3 position;
void main() {
vec3 scaledPosition = position * factors;
gl_Position = vec4(scaledPosition, 1.0);
}
uniform vec3 factors; in vec3 position; void main() { vec3 scaledPosition = position * factors; gl_Position = vec4(scaledPosition, 1.0); }
Translation and scaling have nearly identical forms, differing only in their arithmetic operator. The same cannot be said of rotation.