Transformations

How to 3D

Chapter 2: Triangles and Transformations

Transformations

The shapes that we've rendered so far have been stationary, always stuck to their original coordinates. If we want our renderers to feel interactive or to tell stories, we need some way of making our objects move.

Operations that change the spatial properties of an object are called transformations. Most graphical applications support just three fundamental transformations:

We transform models not by permanently altering their positions in the vertex buffer, but rather by applying mathematical operations on the fly in the vertex shader. Before we learn the mathematics behind them, first develop a visceral feel for their behaviors and parameters by fiddling with this renderer:

Ask yourself some questions as you explore. Here are a few to get you started:

In this renderer, only one type of transformation may be applied at a time. Soon our shapes will run through a gauntlet of scales, rotations, and translations before they are drawn in the framebuffer. Additionally, these transformations are for now restricted to the \(z = 0\) plane because the mathematics behind rotation is simpler in 2D. Soon we'll extend them into 3D.

← UniformsTranslate →