1/30
Looks like no tags are added yet.
Rendering's three steps
(1) Viewing and projection, (2) hidden surface removal, (3) determining surface colour.
Photorealistic vs non-photorealistic rendering
Photorealistic looks like a camera image. Non-photorealistic = illustration, visualization, art, where realism can get in the way.
Full viewing chain
M = Mo Mp Mv (read right to left): Mv lookAt, Mp perspective, Mo orthographic + viewport.
Mprojection
Mo Mp together.
Canonical view volume
The cube [-1, +1]^3 centred at the origin.
Viewport transform (canonical -> screen)
A scale (size 2 -> nx) then a translate (origin to the lower-left). z passes through for the z-buffer.
Pixel centres and screen extent
Pixel centres are at integers 0..nx-1, so the screen covers -0.5 to nx - 0.5.
Display origin at top-left, y down
Flip y: multiply the y scale by -1.
Parallel projection properties
Not photorealistic, but preserves angles and lengths, so you can measure from it. Good for technical drawings.
Orthographic view volume
Axis-aligned box [l, r] x [b, t] x [n, f], bounded by 6 planes: left, right, bottom, top, near, far.
Camera viewing direction convention
Looks down -z (right-handed, +z out of the screen), so visible z values are negative and n > f even though |n| < |f|.
Morth
Maps the orthographic box to the canonical cube with a scale and a translate. Mo = Mvp Morth.
lookAt inputs
e = eye position, g = gaze direction, t = view-up vector.
Goal of the viewing transformation
Put the camera at the origin, looking along -z with y up.
w (camera frame)
w = -g / |g|. Points opposite the gaze. Maps to z.
u (camera frame)
u = (t x w) / |t x w|. Perpendicular to t and w. Maps to x.
v (camera frame)
v = w x u. The true up (t made perpendicular to the view direction). Maps to y.
Mv construction
Rotation with rows u, v, w times translate by -e. Translate the eye to the origin first, then rotate uvw onto xyz.
Mv is the transformation from…
Model (world) space to eye space.
Orthographic viewing matrix
M = Mo Mv
Perspective projection
Farther objects look smaller; size scales with distance. How eyes and cameras see.
Perspective by similar triangles
Screen at distance d: ys = (d / z) y. Perspective = divide by z.
Why homogeneous coordinates for perspective?
Matrices can't divide. Put z into the w slot; the final divide by w does the divide by z.
Simple perspective matrix effect
(x, y, z, 1) -> (x, y, z, z/d), then divide by w -> (dx/z, dy/z, d).
Mp (perspective matrix)
Turns the frustum into the orthographic box. Leaves the z = n plane alone and squashes the far end to the same size.
Why that particular Mp?
Any matrix that divides by z gives perspective; you pick the convenient one that maps to the ortho box.
z' after perspective divide
z' = n + f - fn/z. Non-linear in z; it causes z-buffer precision problems.
x and y after perspective divide
xs = nx/z, ys = ny/z
Why GLM gives lookAt and perspective
They build Mv and Mp (Mprojection) for you.
Parallel vs perspective (review Q)
Parallel: projection lines parallel, size independent of distance, angles/lengths preserved, not realistic. Perspective: lines converge at the eye, divide by z, distant objects smaller, needs homogeneous coords (w = z).