Quiz: meshes, coordinate spaces and projection
Before this unit: Day 51: Marching cubes.
See also: Day 46: Colour; Day 3: Bit depth and noise.
Short questions to test your understanding. Try each on paper first, then open the answer. Conventions: the camera looks down -z in view space; after the divide by w, everything visible lies in the cube [-1, 1]^3.
Q1. Why does an indexed triangle list need less memory than storing three positions per triangle?
How many triangles share a vertex in a closed mesh?
Each vertex of a closed mesh is shared by about six triangles. Indexed, its position (12 bytes) is stored once and each triangle stores three 4-byte indices; as a soup it is stored about six times. For 10^6 triangles: about 18 MB indexed against 36 MB as a soup.
Q2. Two neighbouring triangles of a mesh both list their shared edge as “vertex 5, then vertex 7”. What is wrong, and what will you see?
Winding decides which side is the front.
In a consistently oriented mesh the two triangles traverse the shared edge in opposite directions. Here one of them is wound the other way: its normal points inwards. With back-face culling it disappears (a hole), and its lighting is wrong.
Q3. Why does a direction such as a normal or a light direction get w = 0?
What happens to the translation column of a 4\times4 matrix?
The translation column is multiplied by w. With w = 0 it has no effect: moving an object does not change which way a direction points. Rotations and scales still act on it.
Q4. You want to turn a house about its own centre and then place it at (5, 0, 0). Is the model matrix TR or RT?
The matrix next to the vector acts first.
TR: R turns the house about the origin of model space (its centre), then T moves it. RT would first move it to (5, 0, 0) and then swing it around the world origin.
Q5. The camera moves 1 unit to the left. What happens to the view-space coordinates of every object?
V is the inverse of the camera’s placement.
They all move 1 unit to the right (x increases by 1). The view matrix undoes the camera’s placement, so moving the camera one way is the same as moving the world the other way.
Q6. Why can the perspective projection not be done by a 4\times4 matrix alone, and how is it done?
x_s = n x/(-z).
Dividing by z is not linear, and a matrix product is linear in the coordinates. The matrix copies -z into the fourth coordinate w; the hardware then divides x, y and z by w (the perspective divide).
Q7. With n = 1 and f = 3, a point halfway between the near and far planes gets the NDC depth 0.5, not 0. Why?
After the divide, depth is A + B/z.
Depth after the divide is a function of 1/z, not of z: it changes fast near the camera and slowly far away. With z_\text{ndc} = 2 + 3/z, the point at z = -2 gets 2 - 1.5 = 0.5. Three quarters of the depth range is spent on the nearer half of the distances.
Q8. In an orthographic view, does an object get smaller when it moves away from the camera? Name a use in image analysis.
What is w after an orthographic projection?
No: w = 1, so there is no division by distance; parallel lines stay parallel. Microscopy viewers and maximum-intensity projections are usually orthographic, so that lengths in the image can be compared and measured.
Q9. A vertex has clip coordinates (0.4, 0.2, -2, -0.5). Is it visible? What would happen if it were divided by w right away?
Inside the frustum means -w \le x, y, z \le w.
w < 0: the vertex is behind the camera, so it is not visible. Dividing gives (-0.8, -0.4, 4): the signs flip and the point would appear on the opposite side of the screen. Triangles are clipped against the near plane in clip space, before the divide.
Q10. One camera sees a bright spot at a pixel. Can you tell from this one image how far away the spot is?
Run the pipeline backwards from a pixel.
No. A pixel corresponds to a whole ray from the eye; every point on that ray projects to the same pixel. A second camera at another position gives a second ray, and the spot lies where the two rays meet (stereo).