Scale
To scale a model, we 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 across the pivot.
Scaling is sometimes expressed as vector multiplication. Here position \(\mathbf{p}\) is multiplied by \(\textrm{factors}\):
The factors are often kept the same so that the model doesn't become distorted. This is uniform scaling. Non-uniform scaling is commonly used to achieve squash-and-stretch effects during animation.
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.